Q:

Write a JavaScript program to iterate over all own properties of an object, running a callback for each one

0

Write a JavaScript program to iterate over all own properties of an object, running a callback for each one.

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

const forOwn = (obj, fn) => Object.keys(obj).forEach(key => fn(obj[key], key, obj));
forOwn({ foo: 'bar', a: 1 }, v => console.log(v)); // 'bar', 1

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now