DEV Community

Discussion on: Don’t pay the for-loop tax

Collapse
 
julienetienne_ profile image
Wolfie's just fine • Edited

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.