static/class properties

Andrea Giammarchi andrea.giammarchi at gmail.com
Thu Sep 19 10:14:58 PDT 2013


I cannot remember if that has been considered historically a Java or PHP
error/ambiguity ... I'd rather not repeat that in ES6.

A Class constant should have nothing to do with instances but instances can
have properties that returns that class constant, if needed.

We've got new syntax here so I say this is the easier to
read/write/understand ... no need a big chapter explaining what's going on
^_^

```javascript
class A {
  static A.VALUE = 10;
}
```

or ...

```javascript
class A {
  static {
    VALUE = 10;
  }
}
```

as in [redefine.js](https://github.com/WebReflection/redefine#classes)


Both will desugar in

```javascript
function A(){}
Object.defineProperty(A, 'VALUE', {value: 10});
```

leaving the prototype alone with its own different world problems.

My 2 cents




On Thu, Sep 19, 2013 at 7:23 AM, Boris Zbarsky <bzbarsky at mit.edu> wrote:

> On 9/19/13 9:30 AM, Rick Waldron wrote:
>
>> class A {
>>    const VALUE = 10;
>> }
>>
>> A decision would have to be made for "const VALUE = 10" here: does it
>> mean mean `A.VALUE` and not `var a = new A(); a.VALUE;`?
>>
>
> The current web platform (and hence WebIDL) answer is "both".  So both
> XMLHttpRequest.UNSENT and XMLHttpRequest.prototype.**UNSENT exist and
> have the same value.
>
> -Boris
>
> ______________________________**_________________
> es-discuss mailing list
> es-discuss at mozilla.org
> https://mail.mozilla.org/**listinfo/es-discuss<https://mail.mozilla.org/listinfo/es-discuss>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20130919/f29f950d/attachment.html>


More information about the es-discuss mailing list