I've been using JSDoc 3 for documentation of JavaScript code for years now,
and it recently occurred to me that maybe the "instanceMember" namepath is
a candidate for inclusion in ECMAScript proper:

http://usejsdoc.org/about-namepaths.html

The # operator would effectively be syntax sugar for .prototype.

Some examples:

MyConstructor#method === MyConstructor.prototype.method; // true

class Child extends Parent {
  method () {
    // TODO: do something more than Parent would
    return Parent#method.call(this);
    // equivalent to Parent.prototype.method.call(this);
  }
}

var args = Array#slice.call(arguments, 0);

Now, some of these examples may be anti-patterns in an ES2015 world, but I
wonder whether .prototype.foo is accessed frequently enough in enough code
(even post-ES2015) that there's some merit here.

For me, it would make argument wrangling and ES5 class code more
convenient, and it would also bring extra parity between my JSDoc content
and the actual code it documents.

Have all use cases for this idea already been squashed by ES2015? I realise
there is a high threshold for syntax changes.
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to