Lesson 15/100

Tutorials JavaScript Tutorial

Arrow Functions — Complete Guide

Arrow Functions — Complete Guide: free step-by-step lesson with examples, common mistakes, and interview tips — part of JavaScript Tutorial on Toolliyo Academy.

On this page

JavaScript Tutorial · Lesson 15 of 100

Arrow Functions

BasicsObjects & dataAsync & DOMAdvancedToolsProjects

Beginner · 1 — Learn by example · ~6 min · JS Control Flow & Functions

What is this?

Arrow functions are a shorter way to write functions: (a, b) => a + b. They are common in modern JavaScript and React.

Why should you care?

Less typing for small helpers. Teams use them in array methods like map and filter.

See it live — copy this example

Paste into an HTML file or the browser console (F12). Use Run below when the live editor is available.

const double = (n) => n * 2;
console.log(double(4));

const sum = (a, b) => {
  return a + b;
};
console.log(sum(2, 3));

Run Example »

Edit the code below and click Run to see the result in Toolliyo’s live editor.

Code
Result

What happened?

  • If the body is one expression, you can omit return and braces.
  • Multiple lines need { return ...
  • }.

Practice next

  1. Run double and sum examples.
  2. Rewrite greet as an arrow function.
  3. Use [1,2,3].map(x => x * 2) in the console.
  4. Return an object from an arrow function using parentheses: () => ({ ok: true }).
  5. Use an arrow in setTimeout and log this — compare with function() {}.

Remember

(param) => expression Add { } and return for multiple lines Great for short callbacks

ScriptVerse filter pipeline

Product lists use arrow callbacks in filter and map for concise transformation chains.

Outcome: Arrow functions keep array processing readable in modern React and vanilla JS codebases.

Interview prep for this lesson

Practice these questions aloud after reading—each links to a full structured answer.

Mid PDF Detailed
What are higher-order functions?
Short answer: A higher-order function is a function that takes another function as an argument or returns a function. They are key to functional programming in JavaScript. Example: function greet(name) { return `Hello, $…
Mid PDF Detailed
What are functions in JavaScript?
Short answer: Functions are blocks of reusable code that perform a specific task. Example: function greet(name) { return `Hello, ${name}`; } Example code Functions are blocks of reusable code that perform a specific task…
Junior PDF Detailed
What is the difference between inline-block and block?
Short answer: block elements take full width and start on a new line. inline-block behaves like inline (stays in the same line) but allows setting width, height, margin, and padding. Example code .block { display: block;…
Mid PDF Detailed
Explain the difference between HTML4 and HTML5.
Short answer: HTML5 is the modern evolution of HTML4, introducing better structure, multimedia support, and APIs. Explain a bit more Follow me on LinkedIn: HTML4 mainly focused on document markup, while HTML5 focuses on…
Mid PDF Detailed
Class selector: Targets elements with a class.?
Short answer: .highlight { background: yellow; } .highlight { background: yellow; } .highlight { background: yellow; } .highlight { background: yellow; } .highlight { background: yellow; } .highlight { background: yellow…
Questions on this lesson 0

Sign in to ask a question or upvote helpful answers.

No questions yet — be the first to ask!

JavaScript Tutorial
Course syllabus

JavaScript Tutorial

Tutorial — Basics
Control Flow & Functions
Objects & Collections
Strings, Dates & RegEx
Async JavaScript
HTML DOM & Web APIs
Advanced
Performance & Security
Testing & Tooling
Projects
Toolliyo Assistant
Ask about tutorials, ebooks, training, pricing, mentor services, and support. I use public site content only—not admin or internal tools.

care@toolliyo.com

Need callback? Share your details