
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
What 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.
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; });
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.
Advertisements