JavaScript ES6 brings new syntax and new awesome features to make your code more modern and more readable. It allows you to write less code and do more. ES6 introduces us to many great features like arrow functions, template strings, class destruction, Modules… and more. Let’s take a look.
let
keywordconst
keywordArray.find()
Array.findIndex()
const
is a new keyword in ES6 for declaring variables. const
is more powerful than var
. Once used, the variable can’t be reassigned. In other words, it’s an immutable variable except when it used with objects.
This is really useful for targeting the selectors. For example, when we have a single button that fires an event, or when you want to select an HTML element in JavaScript, use const
instead of var
. This is because var
is ‘hoisted’. It’s always preferable to use const
when don’t want to reassign the variable .