How to refer to the current prototype of a class.
/#!/JoePea
joe at trusktr.io
Sun Jul 31 01:03:04 UTC 2016
Currently we use
```js
class Foo {
bar() {
// we want the current prototype's (HomeObject's?) `baz` method, not
the leafmost prototype's (this') `baz` method.
Foo.prototype.baz()
}
baz() {
// ..
}
}
```
What about a shorthand keyword like `current` for the "current prototype"?
```js
class Foo {
bar() {
// we want the current prototype's (HomeObject's?) `baz` method, not
the leafmost prototype's (this') `baz` method.
current.baz()
}
baz() {
// ..
}
}
```
What about `prototype`, because that word is, afterall, owned by JavaScript
(though more likely to break code than `current`).
```js
class Foo {
bar() {
// we want the current prototype's (HomeObject's?) `baz` method, not
the leafmost prototype's (this') `baz` method.
prototype.baz()
}
baz() {
// ..
}
}
```
Or, since `HomeObject` is a thing, maybe a `home` keyword would be
intuitive, although that is also more likely to break existing code than
`current`?
```js
class Foo {
bar() {
// we want the current prototype's (HomeObject's?) `baz` method, not
the leafmost prototype's (this') `baz` method.
home.baz()
}
baz() {
// ..
}
}
```
Or a symbol?
```js
class Foo {
bar() {
// we want the current prototype's (HomeObject's?) `baz` method, not
the leafmost prototype's (this') `baz` method.
#.baz()
}
baz() {
// ..
}
}
```
*/#!/*JoePea
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20160730/ea8f6291/attachment.html>
More information about the es-discuss
mailing list