Object.prototype.e = function() {
[].forEach.call(this, function(e) {
return e;
});
};
var w = [1,2];
w.e(); // undefined
But this works if I use alert instead
// ...
[].forEach.call(this, function(e) {
alert(e);
});
// ...
w.e(); // 1, 2
The function
e()isn’t returning anything; the inner anonymous function is returning itsevalue but that return value is being ignored by the caller (the caller beingfunction e()(and can the multiple uses of ‘e’ get any more confusing?))