I am wondering if there is a way to fake Array.isArray() with a user-defined object.
From the JavaScript Templates book:
Array.isArray([]); // true // trying to fool the check // with an array-like object Array.isArray({ length: 1, "0": 1, slice: function () {} }); // false
This object obviously fails, but is there any other way to do this? This is just curiosity, and not because I think you could ever embed .isArray() in regular client code (although it would obviously be fantastic to find out if you can!).
javascript
Josh smith
source share