Var: Array is Object


#1

I just stumbled upon this:

var v = Array<var>();
v.isArray(); // true
v.isObject(); // true
v.getObject(); // NULL

It’s because VariantType_Array inherits from VariantType_Object. Is this intended? I figure it might be, to be consistent with JavaScript. In any case, getting true from isObject() and then NULL from getObject() is really surprising.


#2

Yes… IIRC that’s because javascript is a bit quirky. Not sure I’d want to change it…


#3

Ah ok. In that case I suggest adding a short hint to the documentation for isObject: “Returns true if the var is an array or an object”.


#4

Yep, fair enough


#5

In Javascript, everything is an object… {}