Skip to content

Instantly share code, notes, and snippets.

@masautt
Last active September 3, 2019 23:01
Show Gist options
  • Save masautt/66c498235ec24227eb2b63ded69f288c to your computer and use it in GitHub Desktop.
Save masautt/66c498235ec24227eb2b63ded69f288c to your computer and use it in GitHub Desktop.
How to loop through an Object in JavaScript?
var obj = { first: "John", last: "Doe" };
Object.keys(obj).forEach(function(key) {
console.log(key, obj[key]); // first, John
// last, Doe
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment