3 ms·
#this_is_not_a_comment = 6;
by ape4 8y ago
#this_is_not_a_comment = 6;
- xutopia 8y agoThis one was weird but for someone who only does Javascript it might not. # is not a comment in Javascript but is in many other languages I use which really threw me for a loop.
- kbd 8y agoYeah... it's ugly as heck but they're clearly trying to avoid new keywords. I hope the TypeScript folks can convince ECMA to adopt normal keywords like they use: https://www.typescriptlang.org/docs/handbook/classes.html https://www.typescriptlang.org/docs/handbook/classes.html
- maxfurman 8y agoI've read the TC39 proposal and I still don't understand what's wrong with "private".
- manigandham 8y agoYou can have a public field named the same as a private field and all fields in JS are accessed by "this.fieldname" so you need a way to access the private field differently.
- Klathmon 8y agoIt's not just about keywords, it's about shadowing mostly [1]. For example, what does `this.foo` access in an object? the private property `foo`? the public property `foo`? What about if I'm using your object and put a new property `foo` on it after it's created, then what happens? None of the answers to those questions are really good. If the private shadows the public, then how do you access the public? If it's the other way around, then external users can break your private fields by adding a public of the same name, which kind of defeats the purpose... TypeScript can get away with it because it's not really enforced by the runtime, only the typechecker, so their `private` isn't really private outside of TypeScript. [1] https://github.com/tc39/proposal-class-fields/blob/master/PRIVATE_SYNTAX_FAQ.md#whats-this-about- https://github.com/tc39/proposal-class-fields/blob/master/PR...
- goatlover 8y agoIt looks odd, but the pound sign isn't a comment character in JS, so ... I guess it's like @ for Ruby.