Confusing ScriptObjectMirror size() vs mirror.get("length")

2016-12-02 Thread Art Fiedler
Thanks for making it more confusing! ;) The reason I used array.get(iStr) instead of array.getSlot(I) just happened to be because of my previous post about array.getSlot() returning the undefined object. I should however have used getSlot in this example to make it more clear that I knew I was

Re: Confusing ScriptObjectMirror size() vs mirror.get("length")

2016-11-30 Thread Sundararajan Athijegannathan
I think this is not a bug. "length" is not the same as number of properties in an object. For example, if you try this: var a = [3, 5, 66]; a.foo = "nar"; for (var i = 0; i < a.length; i++) print(a[i]); "length" is 3 [and not 4]. keySet size is the number of "keys" (properties). You've to

Confusing ScriptObjectMirror size() vs mirror.get("length")

2016-11-30 Thread Art Fiedler
@Sundararajan When looping an array in javascript I would typically do something like this... for(var i = 0; i < arr.length; i++) { console.log('Index: ' + i + ' = ' + arr[i]); } When looping a javascript array using the ScriptObjectMirror I would initially think to use the same