apparently there is an ecmascript proposal for this syntax: class Foo { a = 1; } which would assign `this.a = 1` on every /instance/, rather than the prototype. unsure how i feel about this. also adds private fields, which i feel very strongly Is Bad https://github.com/tc39/proposal-class-fields …
-
Show this thread
-
Replying to @eevee
I think one of the biggest traps of API design is thinking that something being common means it needs to be a special case.
1 reply 0 retweets 4 likes -
-
Replying to @eevee
Do you have any idea WTF the `static [a];` and `[b];` in that proposal do?
1 reply 0 retweets 0 likes -
Replying to @sgrif
brackets mean "evaluate this expression and use the result as an identifier here". you can already do it with function definitions; it's especially useful if you want to use a Symbol as a name
2 replies 0 retweets 3 likes -
Replying to @eevee
Maybe I'm just a dinosaur, but `this[Symbol.iterator] = function() {... }` seemed fine
1 reply 0 retweets 0 likes -
Replying to @sgrif
lmao fair enough, but this lets you keep it in the class body
1 reply 0 retweets 0 likes -
Replying to @eevee
In my hypothetical world where JS is basically Ruby, `this` in a class body refers to the prototype
1 reply 0 retweets 0 likes -
Replying to @sgrif
leave out `this` and you basically have bracket syntax
1 reply 0 retweets 0 likes
Yeah, after writing that last bit I realized how they came to the bracket syntax since everything else just drops the `this` -- Still opaque from reading if you don't already know it though.
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.