Just a wild guess here, but those "allPageItems" and all are not Js arrays but array-like objects returned by the underlying C++ code in Indesign. They are basically "uninitialised" by the JS engine.
2 people found this helpful
var coll = app.activeDocument.allPageItems
var arr = Array.prototype.slice.call( coll, 0 );
quickNdirty to convert collections to arrays
var testarray=app.activeDocument.allPageItems; $.writeln(testarray.reflect.properties); // --> length,__proto__ testarray=Array.prototype.slice.call( testarray, 0 ); $.writeln(testarray.reflect.properties); // --> 0,1,2,length,__proto__
Great workaround Hans, works like a charm. Thank you very much!
My two pennies:
var a = .concat(app.activeDocument.allPageItems);
instantly set a clean Array that will pass the reflect test as well.
Anyway, it's worth pointing out that a=app.activeDocument.allPageItems already is an Array object, not a collection. There is likely a bug in a.reflect.properties—in the sense MasterDomino illustrated—, but one can check that:
• a.reflect.methods returns all methods we expect from an Array.
So, unless your script actually involves the Reflection object, you can handle app.activeDocument.allPageItems as such, it is indeed an array.