I know (with Lodash or vanilla JS) how to loop generally over an object and get the keys and values. _.forOwn()
and _.forEach()
, etc.
My question is if there is a way to only loop through the keys in a neat shorthand. In other words, can I simplify this code:
_.forEach(myObject, (value, key) => {
// do something quick and important that only needs key
)}
I don't need the value
, only the key
, and so I'm wondering if there's a shorthand to just go through the keys.