Key Concepts

Review core concepts you need to learn to master this subject

Arrow Functions (ES6)

// Arrow function with two arguments const sum = (firstParam, secondParam) => { return firstParam + secondParam; }; console.log(sum(2,5)); // Prints: 7 // Arrow function with no arguments const printHello = () => { console.log('hello'); }; printHello(); // Prints: hello // Arrow functions with a single argument const checkWeight = weight => { console.log(`Baggage weight : ${weight} kilograms.`); }; checkWeight(25); // Prints: Baggage weight : 25 kilograms. // Concise arrow functions const multiply = (a, b) => a * b; console.log(multiply(2, 30)); // Prints: 60

Arrow function expressions were introduced in ES6. These expressions are clean and concise. The syntax for an arrow function expression does not require the function keyword and uses a fat arrow => to separate the parameter(s) from the body.

There are several variations of arrow functions:

  • Arrow functions with a single parameter do not require () around the parameter list.
  • Arrow functions with a single expression can use the concise function body which returns the result of the expression without the return keyword.
Lesson 1 of 1

What you'll create

Portfolio projects that showcase your new skills

Pro Logo

How you'll master it

Stress-test your knowledge with quizzes that help commit syntax to memory

Pro Logo