You can definitely do this with vanilla JS, as stecb has shown, but I think each is the best answer to the basic question of how to do this with lodash.
_.each( myObject.options, ( val, key ) => { console.log( key, val ); } );
As JohnnyHK mentioned, there is also a has method that will be useful for a use case, but from what was originally stated, set might be more useful. Suppose you want to add something to this object dynamically, as you mentioned:
let dynamicKey = 'someCrazyProperty'; let dynamicValue = 'someCrazyValue'; _.set( myObject.options, dynamicKey, dynamicValue );
Here's how I do it based on the original description.
Kevin Leary Jul 25 '19 at 14:30 2019-07-25 14:30
source share