for of looping over object values

for arrays "for in" loops over keys, "for of" loops over values.

would be nice if "for of" iterated over object values also so you didn't have to use Object.values()

would change this:

for (const value of Object.values(object)) {
// code...
}

to this:

for (const value of object) {
// code...
}

That can't work unless Object.prototype has Symbol.iterator, which would both a) not work for Object.create(null), and b) would not make sense for booleans, numbers, dates, regexes, functions, symbols, etc, all of which inherit from Object.prototype.

A solution that didn't depend on Symbol.iterator would fix the first problem, but wouldn't address the second.

1 Like

yeah, makes sense you couldn't implement an iterator on Object.prototype. Too many things non-iterable types inherit from it.