On Oct 6, 2011, at 12:30 PM, Brendan Eich wrote:

> My point was that your "PrototypeJS and Firebug pre-date .hasOwnProperty()" 
> chronology was wrong. Object.prototype.hasOwnProperty was around since ES3. 
> It was not used in Prototype, but on the other hand, the "never extend 
> Object.prototype" rule was also promulgated.


JJB has it mostly right. When Sam wrote Object.extend (which was originally 
Object.prototype.extend), it didn't use hasOwnProperty; my guess is that Sam 
didn't know about it, because most of us were JavaScript amateurs back in the 
day, including myself. When I joined the project over a year later, I remember 
discussing this problem and discovering that Safari 2.0 didn't support 
hasOwnProperty. That, plus the hazard of changing implementation behavior, led 
us to leave things as they were. If I were writing Prototype's Object.extend 
from scratch, I'd definitely want it to copy "own" properties only.

Anyway, I'm in favor of standardizing Object.extend in ES6, but in a way that 
considers only "own" properties (including private names, if so desired). I 
don't think ES6 should copy the exact behavior of Prototype's (flawed) version 
of Object.extend. Whether that takes the form of a method named "Object.extend" 
or a .{ operator… well, that's less important to me, but my vote is for the 
former.

(Keep in mind that the 80% use-case for this sort of thing is merging default 
options with user-supplied options, at least in the code I write. That's a 
simple case that usually involves merging two plain objects without interesting 
__proto__ values. That's not to say that we should ignore the edge cases; but 
let's just keep them in the proper perspective, and not let them hold up 
progress on this front.)


Cheers,
Andrew
_______________________________________________
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to