Var: Array is Object

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.


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

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”.

Yep, fair enough

1 Like

In Javascript, everything is an object… {}