Rick Waldron (2013-10-22T03:37:44.000Z)
domenic at domenicdenicola.com (2013-10-26T03:21:12.726Z)
On Mon, Oct 21, 2013 at 11:26 PM, Andrea Giammarchi < andrea.giammarchi at gmail.com> wrote: > As sanity/integrity check, `Object.assign` should be something like this > to me ... > > ```javascript > for (var property in source) { > if (Object.prototype.hasOwnProperty.call(source, key)) { > if (key in target) { > Object.defineProperty( > target, key, > Object.getOwnPropertyDescriptor( > source, key > ) > ); > } else { > target[key] = source[key]; > } > ``` This is exactly why there is `Object.assign` and `Object.mixin` (originally called `Object.define), because you can't make this semantic decision and assume that it's what all code wants all the time. > ```js > } > } > > ``` Traceur has: ```js function assign(target, source) { var props = $getOwnPropertyNames(source); var p, length = props.length; for (p = 0; p < length; p++) { target[props[p]] = source[props[p]]; } return target; } ``` Which is correct. > If this is what every dev should do in order to have a meaningful version > of current `Object.assign`, > But it's wrong.