I am trying to override the window.alert to pass multiple parameters.
Please someone explain me why for/in inherits Array.prototype.tester's body into list?
Thank you very much.
Array.prototype.tester = function() {
return 'tester';
}
window.alert = function() {
var args = Array.prototype.slice.call(arguments);
var list = [];
for (var i in args) {
list.push(args[i]);
}
return list.join(', '); // WHY???? alerts: "arg1, arg2, function () { return "tester"; }"
//return args.join(', '); // alerts: "arg1, arg2" expected.
}
alert('arg1', 'arg2');