I'd really like to have a strict mode for fields as well: only declared fields exist. Right now typos can ruin everything, when you have this.itemList in the constructor and assign to this.itmeList elsewhere, then spend a half-day scratching you head wondering why some bits of the code don't work!
Thanks for the article ! ,but I have a small remark regarding that javascript has now real classes,it's not true, javascript is always prototype-based, the class keyword is no more than syntactical sugar , because believing the language has real classes can lead to confusion in developement especially when comparing to other class-based languages.
The prototype approach of JavaScript is more flexible than the stuff that other languages are doing. In fact, most people did implement their own class system on top of it, the ES2015 class syntax is just a standardization of these systems.
We're a place where coders share, stay up-to-date and grow their careers.
Some really new stuff I didn't know before! Thanks a heap! ES6 FTW!
Technically not even ES2018, but yes. :)
Dang! It's hard to keep updated with the numbering! :P
yes, every year another JS
I'd really like to have a strict mode for fields as well: only declared fields exist. Right now typos can ruin everything, when you have
this.itemListin the constructor and assign tothis.itmeListelsewhere, then spend a half-day scratching you head wondering why some bits of the code don't work!Guess that's what you get with dynamic typing :D
Isn't "use strict" the solution for that kind of situation?
Sadly no.
TypeScript or Flow are the solution.
Thanks for the article ! ,but I have a small remark regarding that javascript has now real classes,it's not true, javascript is always prototype-based, the class keyword is no more than syntactical sugar , because believing the language has real classes can lead to confusion in developement especially when comparing to other class-based languages.
This is true.
The prototype approach of JavaScript is more flexible than the stuff that other languages are doing. In fact, most people did implement their own class system on top of it, the ES2015
classsyntax is just a standardization of these systems.