I have checked that π
is valid for a JavaScript variable name. Also, when I try writing var π = Math.PI
in the Chrome console, all is fine.
However, when I include the line var π = Math.PI
inside a .js
file written with Sublime Text 2 on a Mac, Chrome complains:
Uncaught SyntaxError: Unexpected token ILLEGAL
I have tried the encodings UTF-8, UTF-16 LE and UTF-16 BE, but none work. When I execute the line console.log('π')
, written inside Sublime Text 2 with UTF-8, Chrome prints:
Ï€
How can I use the JavaScript variable name π
in Sublime Text 2, so that Chrome understands it?