DEV Community

Cover image for What are your fav ES6 features?
Madza
Madza

Posted on

What are your fav ES6 features?

Some of JavaScript ES6 features include:

πŸ”Έ const and let
πŸ”Έ arrow functions
πŸ”Έ template literals
πŸ”Έ default params
πŸ”Έ destructuring
πŸ”Έ import and export
πŸ”Έ promises
πŸ”Έ rest & spread
πŸ”Έ extends keyword
πŸ”Έ classes

Which ones are your favorite?
Which ones do you use the most?

Top comments (12)

Collapse
 
pengeszikra profile image
Peter Vivo

My favourite is: generator functions. Mandatory use for side effect handling. Or write complex flow programming. But I always use const - arrow - destructuring - rest combo in react:

const StatelessFooComponent = ({data, foo:{x, y}, ...props}) => (
 <section style={{position:'absolute', top:y, left:x}}>
   <pre>{data}</pre>
   <pre>{JSON.stringify({...props}, null, 2)}</pre>
 </section>
);
Collapse
 
madza profile image
Madza

Yeah, I guess I forgot generator functions and iterators ;)

Collapse
 
merichard123 profile image
Richard

I use most of them quite a lot, especially with react. My favourite is probably template literals, save me doing messy concatenation with concat or the + operator. I probably use import and export the most along with const and let as I don't use var much anymore.

Collapse
 
madza profile image
Madza

Yup, ES6 features has long time ago become a norm, especially when working with modern libraries/frameworks :)

Collapse
 
bendman profile image
Ben Duncan • Edited

I find async/await greatly simplifies asynchronous flows.

Like others have said, I use destructuring, rest, spread, import/export, arrow functions, const/let, and template literals every day and don't even consider them to be new features at this point. Default params are also quite nice.

Most of my programming for work is functional, but I use extends and classes for personal projects when I'm working on agent-based scientific modeling or genetic algorithms, as I tend to use object-oriented programming for those.

Emergency edit:

The optional chaining operator is great, and pairs well with the nullish coalescing operator!

const foo = { bar: "hi" };

foo.bar?.toUpperCase() ?? "not available"; // "HI"
foo.buzz?.toUpperCase() ?? "not available"; // "not available"
Collapse
 
mohsenalyafei profile image
Mohsen Alyafei

For me, these are just pure basic javascript keywords/functions that must be used anyway in any javascript code. They are no longer "new features"; they are now "old standard features".

We are now thinking of about the use of the ES10/ES11 new features.

Collapse
 
axelledrouge profile image
AxelleDRouge

the one I use the most ? well I don't even think about const and let anymore, I always use them, and then arrow functions too and import and export (I certainly feel when I can't use them)
But my favorite ? the one I use and think "woah thanks es6 for that" it's template literals, so useful, for many things, like styling

Collapse
 
madza profile image
Madza

Template literals and let/const were first features I started to use :)

Collapse
 
nemo011 profile image
Nemo

ES6 is a great upgradation in JS. I also use almost all the features you mentioned above. I love Classes in ES6.

Collapse
 
madza profile image
Madza

I miss something groundbreaking in newest ES versions as ES6 was back in 2015 :)

Collapse
 
patrickweb profile image
Just Patrick

Arrow functions, Destructing and spread operator are my favorites

Collapse
 
madza profile image
Madza

When you get fluent using them, all three are awesome for being so much more productive compared to ES5 approaches :)