When null is not quite null
Well maybe this is obvious to you but it threw me for a while.
Lets say you have an object and you want to check whether it is null...
trace(x==null)
and this shows true.
Its clear that the object x is empty and contains nothing isn't it.
Well actually no.
If x just happens to be an attributes array from an XMLNode it so happens that it will be equal to null and at the same time can contain values...
var x= node.attributes
trace(x==null) // display true
trace(x.age) //displays a valid value for an assigned age attribute..
So does this mean there is no way of finding out if the attributes array is empty without looping over all the attributes with a for(x in attributes) type of check?
Comments
Will ultra-strict equality work? I'm under the assumption that the "===" operation is strict to all parts, as if you do a for...in loop on the element.
trace(x===null)
Haven't tried it yet though
Posted by: Jon | May 26, 2004 04:59 AM