| https://tc39.es/ecma262/multipage/indexed-collections.html#s... > Arrays are exotic objects that give special treatment to a certain class of property names. See 10.4.2 for a definition of this special treatment. I just meant these special properties. The behavior, apart from the square-bracket syntax for construction, can be emulated using Object property descriptors, Symbol.iterator etc, but AFAIK, much of this is retro-fitted. Not disagreeing with the fact that arrays are almost just regular objects in JS, but the "just" in "just objects" does have nuances, AFAIK. JIT Optimizations for non-sparse arrays might just be part of a larger hot-path optimization system, but I think there are still differences. Is it possible to create an object for which Array.isArray
returns true without it being instantiated using an array constructor or other array-returning function, the Array prototype, or square-bracket syntax?E.g. Array.from({"0": 1, "1: 2})
Array.from({length: 2}, (i) => i + 1)
[1, 2]
[...Object.values{"a": 1, "b": 2})]
...all implicitly use the built-in Array prototype. I'm not sure if it's possible to build an array using only primitives and functions from the Object.
namespace, for example. |