Frontend: Day 2 - Strings continued, Booleans and == || === in JavaScript
Indexing
To access an individual character, you can use the character's location in the string, called its index. Just put the
index of the character inside square brackets (starting with [0] as the first character) immediately after the string.
Escaping strings
There are some cases where you might want to create a string that contains more than just numbers and letters. For
example, what if you want to use quotes in a string?
Ex-2
"Hey, "please talk to me.""
Uncaught SyntaxError: Unexpected identifier
If you try to use quotes within a string, you will receive a SyntaxError like the one above.
Because you need to use quotes to denote the beginning and end of strings, the JavaScript engine misinterprets the
meaning of your string by thinking > "Hey, " is the string. Then, it sees the remaining
please talk to me."" and returns a SyntaxError.
If you want to use quotes inside a string, and have JavaScript not misunderstand your intentions, you’ll need a
different way to write quotes. Thankfully,JavaScript has a way to do this using the backslash character( \ ).