DEV Community

7 Exciting New JavaScript Features You Need to Know

Mostafa Gaafar on August 05, 2019

This article has been translated to Japanese by @rana_kualu here https://qiita.com/rana_kualu/items/ee7694aa1cd4ae7f4483 JavaScript (or ECMA Scrip...
Collapse
 
deleteman123 profile image
Fernando Doglio

Nice list! Really looking forward to these. I still think private fields prefixed with "#" is crazy and shouldn't have been accepted, but the rest are cool and I can't wait to use them!
Thanks for sharing!

Collapse
 
mausworks profile image
Rasmus Wennerström

I don't get this one either. Why not conform and use private like in both Java, and TypeScript.

This one is mind boggling.

Collapse
 
gafi profile image
Mostafa Gaafar • Edited

I had the same feeling at first. Then I read the reasons behind it and it made some sense. Long story short: in a dynamically typed language, giving the engine a hint whether the property you're trying to access is public or private makes it much easier to implement without exposing details of internal private fields. Here's the reasoning behind it github.com/tc39/proposal-private-f...

Another advantage of it is that linters can also understand if you're trying to access a private property outside its class and warn you, which would be impossible without a special identifier

Collapse
 
kbiedrzycki profile image
Kamil Biedrzycki

Totally agree. Didn't look at specs to be honest, but why it wasn't problem to introduce static keyword and it is a problem indeed with private? 🤔

Collapse
 
emptyother profile image
emptyother

Agreed on the private field prefix. I kinda hope typescript leaves that one out, but they probably have to include it or they would no longer be a superset of js.

Collapse
 
ulitroyo profile image
Uli Troyo

Good write-up! I'm especially looking forward to nullish coalescing, as it would've solved an annoying but I just had.

I heard about optional chaining from Kyle Simpson, and it looks useful! I'll likewise enjoy trying that out.

I'm personally not thrilled about private or static stuff, but much like classes, I know they'll help passerby JS developers who already use JS as an OO language. As the language of the web, it's probably better if developers of all types encounter as little friction as possible working with JS.... but I'm still scrunching up my nose at it.

Collapse
 
jsn1nj4 profile image
Elliot Derhay • Edited

I think now that JS has classes, the private and static keywords/symbols are only a natural next step.

Still, I have to agree with some others about the # symbol for private. That's bizarre to me.

On the other hand though, I guess you'll get some kind of indication from outside the class that what you're trying to use is private. Hopefully it's helpful in that regard.

Collapse
 
wrldwzrd89 profile image
Eric Ahnell

BigInt in particular is welcome - and the restrictions are there for technical implementation reasons, but in practice they matter less, since you can always convert a Number explicitly to a BigInt. As for the others, they solve some pain points, some specific to JS. Look forward to seeing how people use them.

Collapse
 
nmhillusion profile image
nmhillusion

New features are coming with Chrome 🤔

Collapse
 
spock123 profile image
Lars Rye Jeppesen

For us using Typescript these features are not new.

Great nevertheless

Collapse
 
nmaxcom profile image
Carles Alcolea • Edited

2, 3 and 6.

thepracticaldev.s3.amazonaws.com/i...

PS: Small grammar thingies:
{
"as long as it's reference" : "its",
"We with optional chaining" : undefined
}

Collapse
 
gafi profile image
Mostafa Gaafar

Thanks a lot. Fixed.

Collapse
 
ahmedam55 profile image
Ahmed Mahmoud

Such a helpful article. I learned a lot. Thank you

Collapse
 
alin11 profile image
Ali Nazari • Edited

JavaScript (or ECMA Script) is an evolving language...
ECMAScript is a standard (not a language) that JavaScript implements its details.

Collapse
 
koyemanaung profile image
Ye Man Aung

support issues for my account

Collapse
 
adam_cyclones profile image
Adam Crockett 🌀

Some I didn't know about, fantastic!

Collapse
 
papaponmx profile image
Jaime Rios

I was not awere of weak refs. This might be a great performance improvement for modern web applications.

Thanks for sharing!