var MM = '\' + obj[0]['MM '] + '/';
I get two errors while using this code…
missing; before statement and
unterminated string literal
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The character
\is “special” because it’s used to allow the use of all printable characters in strings. In your case'\'is not a string composed by the only character\, but the beginning of a string starting with the single quote character'.For exampe if you want the string
Hello Andrea "6502" Griffiniyou can use single quotesand if you want single quotes in the string you can do the opposite
But what if you want both kind of quotes in the same string? This is where the escape
\character comes handy:Basically
\before a quote or double quote in a string tells javascript that the following character is just a regular character, with no special meaning attached to it.Note that the very same character is also used in regular expressions… for example if you want to look for an open bracket
[you must prefix it with a backslash because[in a regular expression has a special meaning.The escape is also used to do the opposite… in a string if you put a backslash in front of a normal character you are telling javascript that that character is indeed special… for example
In the above line the
\nsequence means a newline code, so the message displayed will be on two lines (“This is” and “a test”).You may now wonder… what if I need a backslash character in my string? Just double it in that case. In your code for example just use
'\\'.Here is a table for the possible meanings of backslash in strings