Search code examples
javascriptdouble-quotes

Double Quote font causing errors


I'm having trouble writing code because apparently some text editors and code editors and tools and developer tools use different quotes.

I've found ” causes error in javascript vs "

Look closely. The double quotes are different from each other.


Solution

  • Yep, those are different characters. Here you can see the character codes

    '”'.charCodeAt(0); // -> returns 8221
    '"'.charCodeAt(0); // -> returns 34
    

    You can try both of these in Chrome by typing those into the console and seeing the result.

    The first, incorrect double-quote may have been generated by something like Microsoft Word which tries to use fancier quotation marks, but it will not work in Javascript. You should use the normal quotes on your keyboard: "