I was wondering what is difference between these two quotes in javascript “ " as
“ --> this gives an error
However,
" --> this does not
Per the specification, section 11.8.4:
A string literal is zero or more Unicode code points enclosed in single or double quotes...
Syntax
StringLiteral :: " DoubleStringCharactersopt " ' SingleStringCharactersopt '
JS string literals may use single or double quotes, but not smart quotes. They are not recognized as delimiters for a string literal, hence your error:
console.log("Look friends, “fake quotes”!");
With ES6+, template literals were introduced (s11.8.6), which use backticks (```) rather than quotes.
This is somewhat in contrast to JS' rules on variable names, which may use Unicode characters, although they are still not interchangeable.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With