loading...
Cover image for What are your fav ES6 features?

What are your fav ES6 features?

madza profile image Madza ・1 min read

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?

Discussion

markdown guide
 

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>
);
 

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

 

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.

 

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

 

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"
 

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.

 

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

 

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

 

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

 

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

 

Arrow functions, Destructing and spread operator are my favorites

 

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