+ 3
What is difference between single and double quotes?
i am new to java script and dont understand what are double wuotes for, could someone explain this to me?
5 Answers
+ 7
Simple and double quotes works same in JS... the only obvious difference is that to handle them inside themselve you must escape them:
alert("He said \"I love potatoes\" "); // OK
alert('I\'m a little bird'); //OK
Rest is question of tastes... I personnaly keep the habits to use simple quotes, so I can easily embed Html code in strings, with the habit to use double quotes for Html code ^^
+ 1
You can include single quotes in double quotes :
alert('Hey!');//OK
alert('He said "I love potatoes" ');//error
alert("I'm a little bird");//OK
If you don't understand ask !
+ 1
cant i just write normal quote sign, or it wont work so i must use double quote?
+ 1
Ok, now i understand it bettwr ^^
Thanks for explaining <3
0
You can use simple quotes but if one day you have to write a sentence with an apostrophee, it won't work.