Object.mixin, why just for enumerables (?)

medikoo medikoo+mozilla.org at medikoo.com
Thu Oct 3 04:41:04 PDT 2013


Object.mixin, why just for enumerables (?)

This is related to:
http://mozilla.6506.n7.nabble.com/Object-define-Object-mixin-tp265638p265651.html

In a spec we have both Object.assign and Object.mixin.

Object.assign is for copying properties ES3 way, which even in ES5 world is
what you want in most cases (btw. I don't agree with
http://www.nczonline.net/blog/2012/12/11/are-your-mixins-ecmascript-5-compatible/
For 3 years I work strictly with ES5, and I never had a case in which I
wanted to just copy enumerables and preserve getters, it's highly unwanted
in all cases I had).

Object.mixin is for copying definitions, which I find as rare but also valid
use case, e.g. to mimic multiple inheritance by copying properties from one
prototype to other. However this cannot work as intended if it's limited
just for enumerables. All properties in native prototypes are already
defined as not enumerable, and this is also what I follow in my code when I
define models.

So as specified currently I find Object.mixin as a function that I don't
find valid use case for, and I strongly miss something like
Object.assignDefinitions, which will copy properties by descriptors, no
matter whether they're enumerable or not.

/Mariusz




--
View this message in context: http://mozilla.6506.n7.nabble.com/Object-mixin-why-just-for-enumerables-tp293611.html
Sent from the Mozilla - ECMAScript 4 discussion mailing list archive at Nabble.com.


More information about the es-discuss mailing list