Helloooo everyone! π It has been a while since I last posted, I have been rather busy the past 2 weeks!
As the title suggests, I am curious to know what your favourite JavaScript ES6 feature is...π€
I was recently asked this in an interview and it surprised me as I have been learning JS with latest features so I don't quite know which features are ES6 and which are newer... So I answered with what came to mind, and it was Promises
. Since I have been learning about backend development with NodeJS, I have learnt a lot about asynchronous programming which is why I chose that answer (I also talked about async/await, which was not introduced until ES7, oops!). Of course, I had to explain why I chose that particular feature and I talked about the benefit of how it helps eliminate callback hell, improve error handling and how you can use Promise chaining to your advantage.
So, I present to you the same question, what is/are your favourite ES6 feature/s and why? (If you are preparing for an interview, this could be a good practice to answer out loud π).
Top comments (16)
generator function you can get in and leave (yield) so many times, it is perfect for declarative coding time consuming process. Modern usecase is
redux-saga
really old poker example on codepen.io
Really cool, thank you for sharing!
Optional chaining is amazing
That's cool also, though I have not used it much
Iβm a big fan of .forEach() and the related .filter() and .map() methods.
Much cleaner and easier to read than the old C-style iterative loops in my opinion, and a great addition to the language given how much of modern JS and front-end dev involves looping through large amounts of data in some way or another.
I agree, I also like array methods, they are very handy :D
That's really cool, I have not used Proxies before, do you have an example use case you have used in the past?
Here is an example of how I use Proxies in the wild. They're one of my favourite things in JS; the sky is the limit for what you can build using them :D
EDIT: In case that code requires an explanation, here is the documentation.
Wow! A lot going on here, but it looks awesome :D Not sure I understand it all, but thank you for the example.
Do not know what is my favorite one but one cool feature which is on top of my list is default value for function parameters.
There are a lot of great features that came in ES6, but I would agree that Promises are my favorite, especially since they paved the way for async/await. Const, let, and classes are also great.
Probably the new array methods.
Optional chain
Mine are Proxy objects and default symbols that can be used for meta programming.
Thank you for this example!