May 2008
Intermediate to advanced
172 pages
4h 54m
English
In Chapter 3, the hasOwnProperty method was offered as a filter to work around a
problem with the for in statement. Unfortunately,
hasOwnProperty is a method, not an operator,
so in any object it could be replaced with a different function or even a value that
is not a function:
var name;
another_stooge.hasOwnProperty = null; // trouble
for (name in another_stooge) {
if (another_stooge.hasOwnProperty(name)) { // boom
document.writeln(name + ': ' + another_stooge[name]);
}
}