Modern JavaScript
About Lesson

In this JavaScript lesson we are going to learn about JavaScript Arrow Function, Arrow functions are also called fat arrow functions, they are one line functions and are much like Lambda functions in programming languages like Java  and Python. it is a feature on JavaScript ES6.



Now first let’s create our regular function. it is a simple function that takes name as argument and we want to print that name in the output.




We have another type of function that is called anonymous function.




Now let’s create an example of arrow function in JavaScript.




You can also make it simpler.



Now let’s create another arrow function that finds the factorial of a number.



JavaScript Arrow Function Features

As we already have mentioned that Arrow functions are feature that provide shorter syntax for writing function expressions. they are particularly useful for writing shorter and more concise functions. these are some features of arrow functions with code examples:


  1. Shorter Syntax: Arrow functions have a shorter syntax than traditional function expressions.

In this example, the sum function is defined using both a traditional function expression and an arrow function expression. the arrow function expression is more concise and easier to read.


  1. Implicit Return: Arrow functions have an implicit return statement, meaning that the value of the expression is returned without needing to use the return keyword.