Keys of an object?

I have an object for which the value of keys is dynamic
for example

obj ={ a: ‘v1’, b: ‘v2’, r : ‘g2’ }
on another day, the same object would have keys
obj ={ k: ‘v1’, l: ‘v2’, r : ‘g2’ }

how can I parse the objects if key values are not known beforehand ?

Underscore has the function _.keys, which returns all of the object’s keys in strings.

1 Like

Thank, Worked perfect with _,keys using the underscore package

Or you can use the vanilla function (no library needed):

Object.keys(yourObject)

which will give you the same result as underscore _.keys

2 Likes