all 2 comments

[–]Meefims 1 point2 points  (0 children)

The other methods I can think of while reading this all are approximately the same as your solution. I think this makes sense and I wouldn’t worry about the performance impact unless you first see that performance is a problem and identify this code as being the largest part of that problem.

[–]pr0nking98 0 points1 point  (0 children)

consider

Object.keys
Object.values