Premium Only Content

Learn Functions in JavaScript | Day 34 | Arrow And Return Keyword | Web development course 2023
rrow functions are a concise way to write JavaScript functions. They were introduced in ES6 and offer several advantages over traditional function declarations, including:
Conciseness: They are written using shorter syntax.
Lexical this binding: They capture the this value of the enclosing scope.
Implicit return: They can implicitly return the value of the expression in their body.
Here's the basic syntax of an arrow function:
JavaScript
(parameters) => expression
Use code with caution. Learn more
The parameters and the expression are separated by an arrow (=>). If the function has no parameters, you can use empty parentheses.
Return Keyword:
The return keyword is used to explicitly return a value from a function. However, in arrow functions with a single expression in their body, the return keyword is implicit. This means you don't need to write it explicitly, and the expression's value will be the function's return value.
Here are some examples:
1. Single expression:
JavaScript
const double = (number) => number * 2;
const result = double(5); // result will be 10
Use code with caution. Learn more
2. Multiple expressions:
JavaScript
const isEven = (number) => {
if (number % 2 === 0) {
return true;
} else {
return false;
}
};
const number = 8;
const isEvenResult = isEven(number); // isEvenResult will be true
Use code with caution. Learn more
3. Implicit return:
JavaScript
const square = number => number ** 2;
const area = square(10); // area will be 100
Use code with caution. Learn more
Key Points:
Arrow functions are concise and have lexical this binding.
In arrow functions with a single expression, the return keyword is implicit.
You can still use the return keyword explicitly in arrow functions with multiple expressions.
-
LIVE
LFA TV
13 hours agoLFA TV ALL DAY STREAM - WEDNESDAY 7/30/25
4,382 watching -
LIVE
JuicyJohns
2 hours ago $0.85 earned🟢#1 REBIRTH PLAYER 10.2+ KD🟢$500 GIVEAWAY
119 watching -
53:02
The Official Corbett Report Rumble Channel
14 hours agoHow to Leave the Cage - #SolutionsWatch
4.83K2 -
42:47
Outspoken with Dr. Naomi Wolf
16 hours ago"Jonathan Pollard: Are Allies of Israel being Targeted?"
4.01K4 -
1:29:49
Game On!
18 hours ago $1.51 earned10,000 Followers Celebration Stream! Let's Talk Sports!
43K2 -
15:38
SKAP ATTACK
20 hours ago $3.03 earnedA Legacy Tainted: Unpacking the LeBron Steroid Rumors
42.5K12 -
2:04:52
The Confessionals
22 hours agoThe Great Spiritual Hijack — And Why It’s Ending
36.7K7 -
1:49:30
Nick Freitas
16 hours agoHere's Why The Housing Market Is Permanently Broken
30.7K4 -
17:03
Nicholas Bowling
20 hours ago $1.31 earned"Celebrity" Tells Street Preacher His Dad's in the ILLUMINATI
18.7K4 -
2:01:09
BEK TV
23 hours agoTrent Loos in the Morning - 7/30/2025
18.2K