We're a place where coders share, stay up-to-date and grow their careers.
Never rely on the order of keys of objects in JavaScript because by specification the interpretator can order them as it wishes
Not for generic prop names but if you previously "created" incremental prop names:
const obj = {thing-0: 'thing-a', another-thing-1: 'thing-b', 'something-2: 'thing-c'}; ... ... obj[key.value.slice(0,-1) + i] // do something
There could also be situations where you need to accumulate based on the number of props rather than specifically the order of props.
Never rely on the order of keys of objects in JavaScript because by specification the interpretator can order them as it wishes
Not for generic prop names but if you previously "created" incremental prop names:
const obj = {thing-0: 'thing-a', another-thing-1: 'thing-b', 'something-2: 'thing-c'};
...
... obj[key.value.slice(0,-1) + i] // do something
There could also be situations where you need to accumulate based on the number of props rather than specifically the order of props.