Possible Duplicate:
When to Use Double or Single Quotes in JavaScript
single quotes versus double quotes in js
I’m trying to build a Node.js Express web application, and in the tutorial they use ' instead of " quite often, but there is no explanation why.
Can someone please explain the difference? Is this specific to JavaScript, or does it apply to other languages too?
Example:
app.configure('dev')
app.get("/", function (req, res)
Thanks 🙂
In JavaScript, both are equivalent. The only difference is that inside a single-quoted string you don’t have to escape
", and vice versa:Most other languages distinguish the two in some way. For example, in Bash and Perl,
''prevents variables from being expanded inside, so'a$b'is the actual stringa$b, whereas"a$b"is the string consisting ofaplus the value of the variableb. In C, C++, C#, and Java,''is used to create a single character constant, so that'a'means the characterawhereas"a"means a string containing that character.