This piece of code:
var o = {}; o.seven = 7;
and this piece of code:
var o = { seven: 7 };
usually equivalent; but if preceded by this piece of code:
Object.prototype.__defineSetter__('seven', function(x) { alert(x); });
then only the first will warn 7 (because the setter is called o.seven = 7 , but not o = { seven: 7 } ), and only the latter actually sets o.seven to 7 .
ruakh source share