JavaScript has never before had classes. In ES6, classes are introduced. Classes in other object-oriented languages, such C++, Java, PHP, etc., resemble classes in ES6. But they don't operate in precisely the same manner. By employing the "extends" keyword to implement inheritance, ES6 classes make it easier to construct objects and reuse code effectively.
4 Main Features of ES6!
Classes
Promises
Promises are used in JavaScript to handle asynchronous operations. When dealing with several asynchronous activities, where callbacks might lead to callback hell and incomprehensible code, they are simple to manage.
Arrow Functions
The introduction of arrow functions in ES6 gives you a more precise approach to define JavaScript functions. They enable us to write shorter function syntax. Your code will be easier to read and more organized with arrow functions.
Destructuring Assignment
The destructuring assignment syntax is a JavaScript expression that makes it possible to unpack values from arrays, or properties from objects, into separate variables.
//Array Destructuring
let cities = ["Dubai", "Lucerne"];
let [d, l] = cities; // Array destructuring assignment
console.log(d);
console.log(l);