Comments on Sept Meeting Notes

Allen Wirfs-Brock allen at wirfs-brock.com
Sat Sep 28 10:51:21 PDT 2013


On Sep 27, 2013, at 9:44 PM, Kevin Smith wrote:

> 
> 
> All the noise we made about Object.extend was unclear? From jQuery:
> 
> https://github.com/jquery/jquery/blob/master/src/core.js#L157
> 
> Many similar functions, going back to Prototype's Object.extend:
> 
> Object.extend = function(destination, source) {
>   for (var property in source)
>     destination[property] = source[property];
>   return destination;
> };
> 
> Thanks.  I believe this supports my position.  Regardless of how @iterator is defined, consider this:
> 
>     extendObject(target, someObjectWithIterator);
> 
> If `someObjectWithIterator` has an @iterator method (be it string or symbol keyed), I would expect that after this statement runs, `target` would also have that @iterator method.  To write it a different way:
> 
>     extendObject(target, {
>       "@iterator"() {}
>     });
> 
> Or:
> 
>     extendObject(target, {
>       [Symbol.iterator]() {}
>     });
> 
> Either way I would be surprised if the "iterator" function was **not** copied.  I think this example argues for enumerability, at least in some cases.  Or equivalently, not all meta-level hooks appear to want non-enumerability.
> 
> { Kevin }


Note that ES6 provides two built-in functions that provide Object.extend-like functionality.  One that uses enumerability and assignment semantics and one that ignores enumerability and uses property definition semantics:

Object.assign
http://people.mozilla.org/~jorendorff/es6-draft.html#sec-19.1.3.1 

Object.mixin
http://people.mozilla.org/~jorendorff/es6-draft.html#sec-19.1.3.15 

When people start using those, they will be expressing an implicit intent.

It is for legacy libraries such as jquery Object.extend where the intent regarding meta=level properties is unclear.

Allens
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20130928/f38a97ed/attachment.html>


More information about the es-discuss mailing list