Is there a test to find out if an object is an associative array?

Is there a test to find out if an object is an associative array?

Thanks.

+3
source share
2 answers

When using an object as an associative array, you simply add dynamic properties to it with arbitrary values.

for ... in loops iterates over only the dynamic properties of an object, so if you create a for ... in loop and end one loop, you will find out that Object is an associative array.

http://livedocs.adobe.com/flex/3/langref/statements.html#for..in

function isObjectAssociativeArray(obj:Object):Boolean
{
    for (var prop in obj)
    {
        return true;
    } 
    return false;
}
+2
source

getQualifiedClassName , "". , - (Object, Array, String...), .

0

Source: https://habr.com/ru/post/1719040/


All Articles