DEV Community

Cover image for JavaScript Class Improvements

JavaScript Class Improvements

K on November 28, 2017

Cover image by Christiaan Colen on Flickr As you may noticed, JavaScript got real classes with it's ES2015 update, but many people still want bett...
Collapse
 
mangekalpesh profile image
Kalpesh Mange

Some really new stuff I didn't know before! Thanks a heap! ES6 FTW!

Collapse
 
kayis profile image
K

Technically not even ES2018, but yes. :)

Collapse
 
mangekalpesh profile image
Kalpesh Mange

Dang! It's hard to keep updated with the numbering! :P

Thread Thread
 
kayis profile image
K

yes, every year another JS

Collapse
 
mortoray profile image
edA‑qa mort‑ora‑y

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!

Collapse
 
kayis profile image
K

Guess that's what you get with dynamic typing :D

Collapse
 
renannobile profile image
Renan Lourençoni Nobile

Isn't "use strict" the solution for that kind of situation?

Collapse
 
kayis profile image
K

Sadly no.

TypeScript or Flow are the solution.

Collapse
 
hamzaop profile image
Hamza • Edited

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.

Collapse
 
kayis profile image
K

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 class syntax is just a standardization of these systems.