On May 28, 2012, at 1:23 PM, Erik Arvidsson wrote:

> On Mon, May 28, 2012 at 12:19 PM, Nicholas C. Zakas
> <[email protected]> wrote:
>> Is it intentional that the first example uses colons between the property
>> and value while all others use the equals sign?
> 
> Yes this is intentional. We discussed this a bit at the F2F meeting
> and we came up with the proposal to use = for [[Put]] and : for
> [[DefineOwnProperty]]. Having a way to do [[Put]] is important because
> it is common to want to trigger setters.

At added a clarification of this to the strawman....



> 
> For example:
> 
> class Monster {
>  set health(value) {
>    this.barColor = value < 10 ? 'red' : 'green';
>    this._health = value;
>  }
> }
> 
> class GiantSpider extends Monster {
>  constructor() {
>    this.{
>      health = 100
>    }
>  }
> }
> 
> If you use .{health: 100} then the setter would not be invoked and the
> object would not be in a correct state. This example might be a bit
> contrived but using [[DefineOwnProperty]] is not the right answer in a
> lot of cases.
> 

This is especially important for setting values of DOM node properties which 
are generally implemented as accessor properties (ie, getters/setters).   That 
is why I used (thanks to dherman) a DOM element in most of the example that use 
+.

Allen



_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to