Skip to content

Instantly share code, notes, and snippets.

@Lodo4ka
Created September 3, 2018 10:01
Show Gist options
  • Save Lodo4ka/9eb8b794645fc19b16a48453de49e3e8 to your computer and use it in GitHub Desktop.
Save Lodo4ka/9eb8b794645fc19b16a48453de49e3e8 to your computer and use it in GitHub Desktop.
// My example
rows.forEach(element => {
let json = JSON.parse(element.template_source);
for (let key in json) {
if(key === 'details') {
json[key].forEach(element => {
if(element.level !== undefined) {
console.log(element.level);
}
})
}
}
});
// ES6
rows.forEach(element => {
let json = JSON.parse(element.template_source);
for (const key of Object.keys(json)) {
if(key === "details") {
json[key].forEach(details => {
console.log(details.level);
})
}
}
});
// ES7
rows.forEach(element => {
let json = JSON.parse(element.template_source);
Object.entries(json).forEach(
([key, value]) => {
if (key === "details") {
json[key].forEach(details => {
console.log(details.level);
})
}
}
)
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment