Sobes.tech
Junior

What new features of ECMAScript 6 (ES6) are you familiar with?

sobes.tech AI

Answer from AI

  • let and const for block scope of variables.
  • Arrow functions (=>) for concise syntax and lexical this.
  • Classes (class) for object-oriented programming.
  • Template strings (backticks `) for string interpolation and multi-line strings.
  • Destructuring assignment for extracting values from arrays and objects.
  • Default parameters in functions.
  • Rest parameters (...rest) and spread operator (...arr, {...obj}).
  • Promises for asynchronous operations.
  • Modules (import, export) for code organization.
  • Map and Set for data collections.
  • Symbols (Symbol) for unique object property identifiers.
  • Generators (function*) and iterators.
// Example of let and const
let counter = 0;
const PI = 3.14;

// Example of arrow function
const add = (a, b) => a + b;

// Example of template string
const greeting = `Hello, world!`;

// Example of destructuring assignment
const person = { name: 'Ivan', age: 30 };
const { name, age } = person;

// Example of a promise
new Promise((resolve, reject) => {
  // asynchronous operation
  resolve('Done');
});