MSK Institute LogoMSK.Institute
HomeCourses
Book Free Demo➔Sign In
Free Demo➔
MSK Institute LogoMSK.Institute

Leading computer training academy in Shikohabad for software engineering, Python, web development, and digital literacy.

ISO 9001:2015 Certified Center
Follow & Connect
4.9

Programs & Admissions

  • All CoursesCatalog
  • Learning PathsRoadmaps
  • Student ProjectsShowcase
  • Live Classes & ScheduleLive
  • Upcoming Batches
  • Campuses & LocationsHub
  • Verify Certificates
  • Book Free Demo Class

Resources & Tools

  • Free Online Mock TestsAll Tests
  • NIELIT CCC Mock TestFree
  • Course & Career FinderQuiz
  • Study Material Hub
  • All MSK ToolsHub
  • Keyboard ShortcutsNew
  • TypeQuest Speed LabTyping
  • MSK Code PlaygroundCode
  • Interactive Tutorials
  • Quick Cheatsheets

Institute & Contact

  • About MSK Institute
  • Careers & InternshipsHiring
  • Publications & Blogs
  • Gali No. 3, Near Gyan Jyoti Public School,
    Adarsh Nagar, Shikohabad, Uttar Pradesh 283135
  • +91 83930 42166
  • mskshikohabad@gmail.com
  • Hours:Mon – Sat: 8:00 AM – 7:00 PM | Sun: 10:00 AM – 2:00 PM
  • 4.9 ★(38 Google Reviews)
© 2026 MSK Institute. All rights reserved.•Privacy Policy•Terms of Service•Disclaimer•Contact Us

Shikohabad's Leading Computer & Coding Academy

Home
Courses
Live
Material
Arrow Functions (Basic)0%
Study Materials
JavaScript for BeginnersProgress 0%
1.1What is JavaScript?1.2How JavaScript Works in Browser1.3Setting up Environment: VSCode, Live Server
7.1Defining and Calling Functions7.2Function Parameters and Return Values7.3Arrow Functions (Basic)
HomeTutorialsJavaScript for BeginnersArrow Functions (Basic)
Array Basics and Methods

Arrow Functions (Basic)

Beginner12 min read•Updated: 2026-09-15•By Er. Sumit Kumar (MSK Institute)
Study Materials

Introduced in ECMAScript 2015 (ES6), Arrow Functions provide a concise, modern syntax for writing functions. Beyond their compact appearance, arrow functions have important lexical scoping properties that make them indispensable in modern frontend libraries like React.


1. Syntax Evolution: From Regular to Arrow

Let's see how traditional function syntax transforms into an arrow function:

1// 1. Traditional Function Expression:
2const add = function(a, b) {
3 return a + b;
4};
5 
6// 2. Arrow Function (Standard):
7const add = (a, b) => {
8 return a + b;
9};
10 
11// 3. Arrow Function with Implicit Return (Concise Body):
12const add = (a, b) => a + b;

2. The Power of Implicit Return

If an arrow function contains only a single expression, you can:

  1. 1
    Omit the curly braces { ... }.
  2. 2
    Omit the return keyword!

The expression is automatically evaluated and returned:

1// Double a number:
2const double = x => x * 2;
3console.log(double(15)); // 30
4 
5// Capitalize text:
6const shout = msg => msg.toUpperCase();
7console.log(shout("javascript")); // "JAVASCRIPT"
Important Warning
[!WARNING] If you open curly braces { ... }, the implicit return is disabled! You must write return explicitly: ```javascript // ❌ WRONG: Returns undefined because curly braces require 'return'! const multiply = (a, b) => { a * b; }; // ✅ CORRECT: const multiply = (a, b) => a * b; // OR: const multiply = (a, b) => { return a * b; }; ```

3. Returning Object Literals with Implicit Return

If you want an arrow function to implicitly return an object literal, wrap the object in parentheses ({ ... }) so JavaScript doesn't confuse the object braces with function body braces:

1// ❌ FAILS: Engine thinks {} is a function code block!
2const makeUser = (name, age) => { name: name, age: age };
3 
4// ✅ CORRECT: Wrap in parentheses:
5const makeUser = (name, age) => ({ name, age });
6 
7console.log(makeUser("Sumit", 25)); // { name: "Sumit", age: 25 }

4. Arrow Functions as Callbacks

Arrow functions shine brightest as inline callbacks for array methods and event listeners:

1const prices = [100, 200, 300, 400];
2 
3// Clean 1-line transformation:
4const discounted = prices.map(p => p * 0.9);
5console.log(discounted); // [90, 180, 270, 360]
6 
7// Filtering:
8const highPrices = prices.filter(p => p >= 250);
9console.log(highPrices); // [300, 400]

5. When NOT to Use Arrow Functions

Arrow functions do not have their own this, arguments, or prototype:

  • Do not use arrow functions for object methods that rely on this.
  • Do not use arrow functions as class constructors (cannot use with new).

Interactive Quiz• Knowledge Check

Practice Quiz

Question 1
What character sequence defines an arrow function in JavaScript?
Question 2
What is an "implicit return" in an arrow function?
Question 3
How do you implicitly return an object literal from a concise arrow function?
Question 4
What is the output of const calc = (x, y) => { x + y }; console.log(calc(2, 3));?
Question 5
Can arrow functions be used as constructors with the new keyword?
Next Lesson

Array Basics and Methods

Continue learning with hands-on practice, examples, and exercises in the upcoming topic.

Related Lessons

Previous LessonNext Lesson
Function Parameters and Return ValuesArray Basics and Methods

Practice Quiz

Test your understanding of this lesson with 5 questions. Each question has one correct answer.

Mentor-Led Practical Training

Master JavaScript for Beginners with Hands-On Projects

Practice in live mentor-led sessions with real projects, mock tests, and verifiable certification at MSK Institute.

View Full CourseBook Free Demo
PreviousNext
PreviousPrevNext