2 ms·
That's because arrays happen to override the special [Symbol.iterator] method: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects
by azernik 7y ago
That's because arrays happen to override the special [Symbol.iterator] method:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/@@iterator https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe...
Arrays are objects of class Array which have special literals, override the toString() method, and update the non-enumerable "length" property on certain operations.
Try calling Object.keys([1, 2, 3]), or even better try Object.getOwnPropertyNames([1, 2, 3])