Destructuring and evaluation order

Allen Wirfs-Brock allen at
Fri Apr 25 12:07:47 PDT 2014

On Apr 25, 2014, at 11:45 AM, Oliver Hunt wrote:

> o = {__proto__: {set foo() {print(“bar”)}}
> = (o.__defineSetter__(“foo”, function(){ print(“foo”)})), 5

1) o.f evaluates to a Reference whose base is the value of 0 and whose referenced name is "foo".  No lookup occurs at this point.
2) o.__defineSetter__  creates an accessor own property on o
3) a PutValue is done using the reference from step 1.  It does a property lookup  and finds/uses the setter defined in step 2
4) print("foo" ) happens

More information about the es-discuss mailing list