0% found this document useful (0 votes)
10 views7 pages

JS PPT 6

Uploaded by

freefireop868
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views7 pages

JS PPT 6

Uploaded by

freefireop868
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 7

Program : Specialisation : Javascript- Basic To Advance

Unit 1: Topic 06
Topic 05: Arrow Function
JavaScript Arrow Function

Arrow functions were introduced in ES6.


Arrow functions allow us to write shorter function syntax:

let myFunction = (a, b) => a * b;


Before Arrow:
hello = function() {
return "Hello World!";
}

With Arrow Function:

hello = () => {
return "Hello World!";
}
Arrow Function With Parameters:

hello = (val) => "Hello " + val;

Arrow Function Without Parentheses:

hello = val => "Hello " + val;


When (and why) you should use ES6 arrow functions — and
when you shouldn’t

1. It’s much shorter

2. We are able to omit the curly braces and the return statement
due to implicit returns

3.Single parameter
With these functions, parentheses are optional:
x => 42 || (x) => 42

You might also like