[Proposal] New syntax for lazy getters
T.J. Crowder
tj.crowder at farsightsoftware.com
Tue Jun 12 12:02:44 UTC 2018
On Tue, Jun 12, 2018 at 12:31 PM, Aadit M Shah <aaditmshah at fastmail.fm>
wrote:
> Classes in JavaScript don't allow assignments within the class body.
Hence,
> the following code is invalid:
>
> class Test {
> x = 123; // This throws an error.
> lazy random = this.x + Math.random(); // Similarly, this should be
> invalid.
> }
Andrea was using syntax from the [class fields proposal][1], currently at
Stage 3 and fairly commonly used via transpilation (he said "class fields"
later in the post, but didn't emphasize it).
-- T.J. Crowder
[1]: https://github.com/tc39/proposal-class-fields
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20180612/9684a7fc/attachment.html>
More information about the es-discuss
mailing list