T
Tim Streater
I have a JavaScript array, myArray. I happen to know that let's say
element 27 is undefined - it's never been created. It appears that I can
detect this with:
if (myArray[27]==null)
{
alert (myArray[27]);
}
The alert puts up 'undefined'. Is it valid to be able to detect the
undefined stater of element 27 in this way?
Initially I thought perhaps that the act of accessing the element
created it and set it to null, but apparently not if the alert is
anything to go by. Or is this just a quirk of Safari?
element 27 is undefined - it's never been created. It appears that I can
detect this with:
if (myArray[27]==null)
{
alert (myArray[27]);
}
The alert puts up 'undefined'. Is it valid to be able to detect the
undefined stater of element 27 in this way?
Initially I thought perhaps that the act of accessing the element
created it and set it to null, but apparently not if the alert is
anything to go by. Or is this just a quirk of Safari?