Don’t use future reserved words as identifiers in JavaScript
Just a quick note: I found recently that some browsers don’t complain when I use future reserved words as identifiers in JavaScript. Specifically, I used char as a variable name, and no Windows browser had a problem with it — but when I tested on Mac, both Safari and Firefox complained. Apparently there are differences in JavaScript implementation between the Windows and Mac versions of Firefox 1.5!
Nitty-gritty details: the ECMA-262 spec defines reserved words and future reserved words in section 7.5.1. Many OO-ish keywords like implements are reserved for the future, as well as specific data types like int and … you guessed it, char.
Further Reading:






Confirmed, co-incidentally, with Safari 1.3. Firefox 1.5 had no problem, though.
Bill Gates
2 Feb 06 at 8:03 pm
That’s common practice.
Rock and Roll
21 Jun 07 at 6:27 am
Don’t forget that Netscape’s Javascript has Java compatibility baked in, so you can refer directly to things like
java.util.Vectorin your scripting. The implication is that all Java reserved words and top-level package names (java, javax, and sun, and probably com, org, net, and edu as well) are reserved in Netscape’s version of ECMAscript.Tim McCormack
7 Mar 09 at 2:08 pm
I didn’t know that!
Xaprb
7 Mar 09 at 2:28 pm