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.
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
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.