loading...

Discussion on: Symbols in ES6 - A Quick Guide

Collapse
brucknert profile image
Tomas Bruckner

Nice article, but I think there is a typo.

const foo = {
name: 'Ben',
age: 25,

}

for(let val of foo) {
console.log(val) // Ben, 25
}

This should throw TypeError, because objects are not iterable. Maybe you meant for...in ?

Collapse
hardy613 profile image
Scott Hardy
for(let val of Object.entries(foo)) {
    console.log(val) // ['name','Ben'], ['age',25]
}

developer.mozilla.org/en-US/docs/W...