I have come across an anomaly between Firefox and Node.js. Given the following code:
'use strict';
const obj = {};
for (let f of ['left', 'right']) {
obj[f] = function() {
return f;
};
}
console.log(obj.left());
console.log(obj.right());
Firefox (48.0) outputs
right
right
while Node.js (6.4.0) outputs
left
right
Both on Ubuntu 14.04. I didn't have the possibility to test with other ECMAScript engines.
Any idea what is the reason for the difference, and which implementation is correct with respect to the specification?