just try it and see

https://repl.it/@caub/obj-vs-map-perf

2018-04-24 20:29 GMT+02:00 somonek <[email protected]>:

> Thanks, hat's probably what I'll do.
>
> I was also thinking looking at @Augusto's approach that if you replace the
> object with a Map you can iterate as Augusto mentioned
> const [firstProp, secondProp, ...othersKeys] = myMap;
> and the order of items should not be a worry.
>
> Any comments on Map's performance in such a case?
>
> On Tue, Apr 24, 2018 at 8:22 PM, T.J. Crowder <
> [email protected]> wrote:
>
>> On Tue, Apr 24, 2018 at 7:07 PM, Jordan Harband <[email protected]> wrote:
>> > Regardless of what's in the spec, relying on objects having an order
>> among
>> > their properties violates the conceptual mental model of objects: a bag
>> of
>> > unordered key/value pairs.
>> >
>> > If you want to convert an array - the best way to preserve order - into
>> an
>> > object for "performance" reasons, then you may also want to preserve an
>> > array of IDs so that ordering can be relied upon.
>>
>> Absolutely agree. As I said originally, relying on the order of the
>> properties in the object is almost always a bad idea.
>>
>> @somonek, an object with an array of keys is probably your best
>> solution. Wrap it up in an object with an API that all of the code
>> updating it can use, so you don't have consistency issues. You could
>> even give it an iterator. :-)
>>
>> -- T.J. Crowder
>>
>
>
> _______________________________________________
> es-discuss mailing list
> [email protected]
> https://mail.mozilla.org/listinfo/es-discuss
>
>
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to