Skip to content

Instantly share code, notes, and snippets.

@leonardreidy
Last active September 27, 2019 11:10
Show Gist options
  • Save leonardreidy/e92dcdc0c34f268499e4109cbc710c6e to your computer and use it in GitHub Desktop.
Save leonardreidy/e92dcdc0c34f268499e4109cbc710c6e to your computer and use it in GitHub Desktop.
let ob = { age: 41, name: 'Leonard', profession: 'JavaScript Developer' };
let looped = []
for(const key of Object.keys(ob)){
looped.push({ [key]: ob[key] })
}
console.log(looped) // logs [{ age: 41 }, { name: 'Leonard' }, { profession: 'JavaScript Developer' }]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment