I am wondering about customizing the window.alert function in order to pass multiple parameters.
Can anyone offer an explanation as to why the for/in loop inherits the body of Array.prototype.tester into the list array?
Your insight is greatly appreciated.
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');