Answers for "js loop through object properties"

7

javascript loop through object values

var myObj = {foo: "bar", baz: "baz"};
Object.values(myObj).map((val) => {
console.log(val);
})
// "bar" "baz"
Posted by: Guest on June-11-2020
2

javascript loop through object properties

for (var prop in obj) {
    if (Object.prototype.hasOwnProperty.call(obj, prop)) {
        // do stuff
    }
}
Posted by: Guest on April-13-2020

Code answers related to "js loop through object properties"

Code answers related to "Javascript"

Browse Popular Code Answers by Language