Next →

ES6 Features in JavaScript

ES6 introduced several new features to make JavaScript cleaner and more powerful.

let and const

let allows you to declare block-scoped variables.
const declares block-scoped constants that cannot be reassigned.

let count = 10;
count = 15; // allowed

const name = "Alice";
// name = "Bob"; // Error: Assignment to constant variable.

Arrow Functions

Arrow functions provide a concise syntax for writing functions.

// Traditional function
function add(a, b) {
  return a + b;
}

// Arrow function
const add = (a, b) => a + b;

Arrow functions also do not have their own this context, which changes how this behaves inside them.