Tuesday, 10 December 2019

syntax - Double quotes vs single quotes in JavaScript











I am wondering if there is a difference between using single quotes vs double quotes in JavaScript (JQuery selectors etc.).



Both seem to work just fine, so is there a difference?


Answer




The difference is that you don't need to escape single quotes in double quotes, or double quotes in single quotes. That is the only difference, if you do not count the fact that you must hold the Shift key to type ".


No comments:

Post a Comment

php - file_get_contents shows unexpected output while reading a file

I want to output an inline jpg image as a base64 encoded string, however when I do this : $contents = file_get_contents($filename); print ...