JavaScript 1.2 Must Die
I’m kind of shocked nowadays when I see anyone using the language="JavaScript" attribute on <script> tags. But I’ve noticed a disturbing trend recently: the user of language="JavaScript1.2" seems to be everywhere.
For those who don’t remember, initially you specified the version of JavaScript in the language attribute. That was all fine and good, but the browser would default to the most recent version of JavaScript if a version wasn’t specified (browsers have the same behavior now). When you specify a version, it forces the browser to use it. So what’s the big deal? JavaScript 1.2 has some different behavior from the rest of JavaScript:
- No support for Unicode characters.
- Array initialization with a single number creates an array with the number as its sole item instead of using it as the array length.
- The
splice()method return an object if only one item is removed and an array if more than one item is removed instead of always returning an array. - Date behavior is platform-dependent instead of platform-independent.
- Boolean objects with a value of false evaluate to false even though all objects should evaluate to true when converted to a Boolean value.
- The == and != operators do not convert values for comparison, which is the default in JavaScript. They behave like === and !==.
These are important differences that can really make a difference in your code. Do yourself and the rest of us a favor, kill JavaScript 1.2 now! Figure out why you’re using it, make the code corrections, and make the web a better place.
Note: It appears that Firefox 1.5 will now ignore the version even if specified and always use the latest JavaScript engine.
Disclaimer: Any viewpoints and opinions expressed in this article are those of Nicholas C. Zakas and do not, in any way, reflect those of my employer, my colleagues, Wrox Publishing, O'Reilly Publishing, or anyone else. I speak only for myself, not for them.
Both comments and pings are currently closed.




5 Comments
thanks for the info!
Tyler on January 22nd, 2006 at 10:19 pm
can i got the free downloaded html editor wiht the latest version
Sandy on January 23rd, 2006 at 5:00 am
Has anyone ever thought/implemented an alternative to JavaScript? I really (really!) loathe the language, yet have to use it almost daily. (LUA anyone?)
Alex on February 21st, 2006 at 7:04 am
Boy Alex, sorry to hear that. I love JavaScript. As for alternatives, Microsoft invented VBScript, but it never really caught on since only IE implemented it.
Nicholas C. Zakas on February 21st, 2006 at 4:40 pm
I agree, I hate Javascript.. That’s the reason I love the Validation controls in Web Devloper from Microsoft.. Visual Studio that is..
Tim
Tim on February 27th, 2006 at 4:00 pm
Comments are automatically closed after 14 days.