In JavaScript, from my understanding, the below are all same:
var carter2 = new String();
var carter2 = '';
var carter2 = "";
Which one is the most preferred?
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.
Don’t use
Because
But
However, because of type coercion, the following works (Thanks to Rocket for pointing it out)
Single and double quotes don’t matter, except for what quotes need to be escaped.
Many others have noted that single quotes are better when creating HTML strings, since XHTML expects attributes to have double quotes, and you won’t need to escape them.