Object.define ==> Object.mixin??

Brandon Benvie brandon at brandonbenvie.com
Wed Dec 12 10:42:52 PST 2012

A contrived example but it demonstrates the problem

Object.mixin({}, Proxy({ a: 5, b: 10, c: 20 }, {
  getOwnPropertyDescriptor(target, key){
    if (key === 'b' && Math.random() * .5) {
      throw 'halt';
    return Reflect.getOwnPropertyDescriptor(target, key);

In ES5 rules there's no way to know whether 'c' will be in the returned
object or not, so that demonstrates actual non-determinism. The more common
case is a deterministic result that's unobvious to the developer as to be
nearly the same effective result.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20121212/f3d0f51d/attachment.html>

More information about the es-discuss mailing list