Ideas on type hinting and named parameters

Andrea Giammarchi andrea.giammarchi at gmail.com
Tue Jun 9 19:38:14 UTC 2015


how about introducing a well known concept in JS as `own` ?

```js
class Person {
  static name String: "A person name"
  own name String: "anonymous"
  own items Array: []

  constructor(name) {
    if (name) this.name = name;
  }

}

var anon = new Person,
      me = new Person('AG');

anon.items;  // []
me.items;    // []

me.items === anon.items; // false

Person.name; // "A person name"

anon.name;   // "anonymous"
me.name;     // AG"
```

thoughts?




On Tue, Jun 9, 2015 at 7:38 PM, Kevin Smith <zenparsing at gmail.com> wrote:

> Also static properties are on __proto__, so it seems a bit strange that
>> instance properties would not also be on .prototype. Somewhat of a
>> consistency issue I suppose.
>>
>
> Methods declared as "static" in ES6 are defined on the constructor
> itself.  Apparently, "static" data properties in TS are defined on the
> constructor as well.
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20150609/cc83794d/attachment.html>


More information about the es-discuss mailing list