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.

Technorati Tags:No Tags

You might also like:

  1. Browser variations in RegExp.exec()

2 Responses to “Don’t use future reserved words as identifiers in JavaScript”


  1. 1 Bill Gates

    Confirmed, co-incidentally, with Safari 1.3. Firefox 1.5 had no problem, though.

  2. 2 Rock and Roll

    That’s common practice.

Leave a Reply

Please do not use this blog to get help with problems or bugs in Maatkit or innotop: use the Sourceforge forums, mailing list, or bug trackers. If you're asking for help with MySQL, please use the MySQL mailing list instead. I'm writing a book and my time is extremely limited :-)