Loop through properties in JavaScript object with Lodash

后端 未结 7 1953
闹比i
闹比i 2021-02-01 00:01

Is it possible to loop through the properties in a JavaScript object? For instance, I have a JavaScript object defined as this:

myObject.options = {
  property1:         


        
7条回答
  •  遥遥无期
    2021-02-01 00:40

    For your stated desire to "check if a property exists" you can directly use Lo-Dash's has.

    var exists = _.has(myObject, propertyNameToCheck);
    

提交回复
热议问题