Object.assign()

Ariya Hidayat ariya.hidayat at gmail.com
Thu Oct 18 07:34:34 PDT 2012


> 2. If the last parameter is boolean, then it's created as
> includeNonEnumerable:
>
> Object.assign(desc, source1[, source2, ... sourceN, includeNonEnumerable);
>
> Example;
>
> Object.assign({a: 10}, {b: 20}, Object.defineProperties({}, {c: {value:
> 30}}), true); // {a: 10, b: 20, c: 30}

That's a slightly dangerous path due to the so-called "Boolean Trap".
See e.g. http://ariya.ofilabs.com/2011/08/hall-of-api-shame-boolean-trap.html.


-- 
Ariya Hidayat, http://ariya.ofilabs.com
http://twitter.com/ariyahidayat


More information about the es-discuss mailing list