Archive for June 6th, 2005

Object.prototype is verboten

Monday, June 6th, 2005

It is not seldom that you see people messing with Object.prototype. This is very bad because it breaks the object-as-hash-tables feature in javascript. Basically, the following is a very common scenario:
var obj = {a: “A”, b: “B”, c: “C”, d: “D”};
for (var key in obj) {
doSomething(key, obj[key], obj);
}

if (”b” in obj) {
[...]