I tend to agree with the article author about the use of a # (or indeed any punctuation mark) for private fields. I think it is just a personal preference thing though. Is there any publicly available discussion that shows what lead to this decision? If fields in class definitions are incorporated I would like it to simultaneously make the field names in scope for any methods within the class definition. class Fish e…
What's New in JavaScript for 2019
31–40 of 85 posts
Re: What's New in JavaScript for 2019
#32I might get heat for this but personally I find the JavaScript ecosystem to be a mess. There are so many changes to the language that are done aggressively which I think are done without much thought. For example, the promises API, now we also have async/await. The module system, with require(s), then import/export, and there's browser JS and system JS (node), and npm and now yarn, then your build system, with webpac…
Having said that, looking at the code sample it's looking quite nice (ignoring the #'s).
Re: What's New in JavaScript for 2019
#33I might get heat for this but personally I find the JavaScript ecosystem to be a mess. There are so many changes to the language that are done aggressively which I think are done without much thought. For example, the promises API, now we also have async/await. The module system, with require(s), then import/export, and there's browser JS and system JS (node), and npm and now yarn, then your build system, with webpac…
Ryan Dahl seemed to imply that promises were a necessary pre-requisite for async/await. https://medium.com/@imior/10-things-i-regret-about-node-js-r... I don't have the actual transcript so summarizing based off of someone else's comments: * I added promises to Node in June 2009 but foolishly removed them in February 2010. * Promises are the necessary abstraction for async/await. * It's possible unified usage of prom…
Re: What's New in JavaScript for 2019
#34Re: What's New in JavaScript for 2019
#35I might get heat for this but personally I find the JavaScript ecosystem to be a mess. There are so many changes to the language that are done aggressively which I think are done without much thought. For example, the promises API, now we also have async/await. The module system, with require(s), then import/export, and there's browser JS and system JS (node), and npm and now yarn, then your build system, with webpac…
Ryan Dahl seemed to imply that promises were a necessary pre-requisite for async/await. https://medium.com/@imior/10-things-i-regret-about-node-js-r... I don't have the actual transcript so summarizing based off of someone else's comments: * I added promises to Node in June 2009 but foolishly removed them in February 2010. * Promises are the necessary abstraction for async/await. * It's possible unified usage of prom…
Re: What's New in JavaScript for 2019
#36so static is `static` but private is `#` ? I wonder whats the reasonig behind it? `private` is already a reserved word in JS, why not just use it? https://www.w3schools.com/js/js_reserved.asp
I was against it at first, but after reading through that document, i'm on their side now. It'll be a small but useful addition in some situations, and it's scope is extremely limited.
https://github.com/tc39/proposal-class-fields/blob/master/PR...
Re: What's New in JavaScript for 2019
#37The only thing that still blows my mind are the private fields and methods. I understand there has been plenty of debate about it, but have not followed the conversation. I really hope that syntax does not get finalized.
Yes. I've read some of the reasoning behind choosing the syntax. Regardless of the issues, I think going with the current proposed syntax is a terrible mistake.
Re: What's New in JavaScript for 2019
#38I tend to agree with the article author about the use of a # (or indeed any punctuation mark) for private fields. I think it is just a personal preference thing though. Is there any publicly available discussion that shows what lead to this decision? If fields in class definitions are incorporated I would like it to simultaneously make the field names in scope for any methods within the class definition. class Fish e…
Re: What's New in JavaScript for 2019
#39so static is `static` but private is `#` ? I wonder whats the reasonig behind it? `private` is already a reserved word in JS, why not just use it? https://www.w3schools.com/js/js_reserved.asp
I would've preferred the "this.private.fieldname" instead but # is what ended up winning.
Re: What's New in JavaScript for 2019
#40so static is `static` but private is `#` ? I wonder whats the reasonig behind it? `private` is already a reserved word in JS, why not just use it? https://www.w3schools.com/js/js_reserved.asp
I feel like i'm spamming this link every time the private fields stuff comes up, but take a look at the FAQ, it explains the reasoning behind it and why they didn't go with alternate options (like underscore, private, or others). I was against it at first, but after reading through that document, i'm on their side now. It'll be a small but useful addition in some situations, and it's scope is extremely limited. https…
> this is already a source of enough confusion in JS; we'd prefer not to make it worse
> Property access semantics are already complicated, and we don't want to slow down every property access just to add this feature.
> [private x] in JavaScript this would silently create or access a public field
Pardon me, but # as a declaration method of privates is an abomination.