Skip to content
Justice Tech School

Arrow Functions

An arrow function uses => and can drop the braces and return keyword when the body is one expression. With one parameter you may drop the parentheses too.

Arrow functions do not have their own this, which makes them handy inside methods and callbacks.

Example
const square = (n) => n * n;
const add = (a, b) => a + b;
const greet = (name) => {
  const text = "Hello, " + name;
  return text;
};
console.log(square(5));
console.log(add(2, 3));
console.log(greet("Ada"));
console.log([1, 2, 3].map((n) => n * 2));

Exercise

Write the arrow.

const double = (x)  x * 2;

Quiz Test

What is special about this in arrow functions?

These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.