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
Basics → Objects & data → Async & DOM → Advanced → Tools → Projects
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.
What happened?
- If the body is one expression, you can omit return and braces.
- Multiple lines need { return ...
- }.
Practice next
- Run double and sum examples.
- Rewrite greet as an arrow function.
- Use [1,2,3].map(x => x * 2) in the console.
- Return an object from an arrow function using parentheses: () => ({ ok: true }).
- 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.
Sign in to ask a question or upvote helpful answers.
No questions yet — be the first to ask!