How to refer to the current prototype of a class.
Claude Pache
claude.pache at gmail.com
Sun Jul 31 11:15:04 UTC 2016
> Le 31 juil. 2016 à 05:12, Michał Wadas <michalwadas at gmail.com> a écrit :
>
> this.constructor.prototype.baz
>
>
No, that is the prototype of the class of the object, which may reasonably be a subclass (and which can be anything in the most general cases).
What is the issue with just `Foo.prototype`?
—Claude
>> On 31 Jul 2016 3:03 a.m., "/#!/JoePea" <joe at trusktr.io> wrote:
>> 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
>>
>> _______________________________________________
>> es-discuss mailing list
>> es-discuss at mozilla.org
>> https://mail.mozilla.org/listinfo/es-discuss
> _______________________________________________
> es-discuss mailing list
> es-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20160731/4b3ea38c/attachment.html>
More information about the es-discuss
mailing list