@mathias I’ve read through some of the V8 articles, but can’t find a definitive answer: is it a bad idea to add a property to an Array: arr.isSomething = true? Mixing properties and elements when iterating the array is in the hot path? Better to make a Class with array as prop?
It depends on your use case. If what you need is a simple array (i.e. mostly indexed access, with all elements being the default writable/enumerable/configurable) with some additional properties, it sounds like the way to go.
-
-
If you mostly need (non-array-index) keyed access, and only need indexed access a few times, consider using a Map. In general, you should just do whatever you think makes the most sense.

-
Array it is. Thank you, wise sensei!
- 1 more reply
New conversation -
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.
JavaScript, HTML, CSS, HTTP, performance, security, Bash, Unicode, i18n, macOS.