- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to define an Arrow Function in JavaScript?
An arror function is a Fat Arrow function in JavaScript. Fat arrow function as the name suggests helps in decreasing line of code. The syntax => shows fat arrow. This also avoids you to write the keyword “function” repeatedly.
Syntax
Here’s the syntax −
argument => expression
Use the following for more than one argument −
(argument1 [, argument2]) => expression
Let’s compare a function with and without fat arrow −
Function in JavaScript
var rank = [7,8,9]; var display = rank.map(function(num) { return num * num; });
Define Fat Arrow function in JavaScript
var rank = [7,8,9]; var display = rank.map((num) => num*num); document.write(arr)
Arrow function definitely reduces the code lines.
- Related Articles
- What is an Arrow Function in JavaScript?
- How to access 'this' keyword inside an arrow function in JavaScript?
- How to define a function in JavaScript?
- How to define custom sort function in JavaScript?
- How to define a JavaScript function using Function() Constructor?
- What is a fat arrow function in JavaScript?
- How to define global variable in a JavaScript function?
- How do we use function literal to define a function in JavaScript?
- How to define functions inside a function body in JavaScript?
- How to define rest parameter for a function in JavaScript?
- How to define a JavaScript function using the expression?
- How to define methods for an Object in JavaScript?
- How to create an arrow in base R?
- Arrow functions in Javascript
- How to make an arrow that loops in Matplotlib?

Advertisements