Node.js: for each … in not working
for (var i in conf) {
val = conf[i];
console.log(val.path);
}
Unfortunately node does not support for each ... in
, even though it is specified in JavaScript 1.6. Chrome uses the same JavaScript engine and is reported as having a similar shortcoming.
You'll have to settle for array.forEach(function(item) { /* etc etc */ })
.
EDIT: From Google's official V8 website:
V8 implements ECMAScript as specified in ECMA-262.
On the same MDN website where it says that for each ...in
is in JavaScript 1.6, it says that it is not in any ECMA version - hence, presumably, its absence from Node.