Javascript reserved words in Internet Explorer
It seems that all IE installations are not created equal, especially when versions of Javascript (or is that JScript) are involved. An example in point is when using a script to detect the length of a radio button array.
By default, a radio button array of more than one item will return its length when referenced by its length property. However, if the radio button is part of a collection totalling just one, Javascript will return a value of undefined as it doesn't choose to consider a one item list as an array. Which is fair enough I suppose.
Anyway, the code below works fine with most versions of IE, and indeed our good friends Mozilla, where undefined is presumably declared as a keyword such as true or null.
if (document.forms[0].radioArray.length == undefined) {
...handling code...
}
Other times though, IE (of course) will fail rather unceremoniously with the briefly confusing message "'undefined' is undefined". The correct way around this seems to be to use the typeof feature to return a string value, similar the code below.
if (typeof document.formName.radioArray.length == "undefined") {
...handling code...
}