Javascript Arrow Function

JS Code Snippets Arrow Function
Share:

About

In this code snippet, we’ll learn how to use arrow functions in Javascript.

Arrow functions are nothing more than “syntactic sugar” to make writing a function a bit shorter. Both examples below achieve the same thing but the second one is just a bit more compact that’s all.

Let’s see the code example below.

Code:

//1. way//////////////////////////////////////////

const someFunction = function(){
	console.log("I am a function.");
} 

someFunction();

//////////////////////////////////////////////////


//2. way//////////////////////////////////////////

const someOtherFunction = () => {
	console.log("I am another function.");
}

someOtherFunction();

//////////////////////////////////////////////////

Resulting output:

Share:

Leave a Reply

Your email address will not be published. Required fields are marked *

The following GDPR rules must be read and accepted:
This form collects your name, email and content so that we can keep track of the comments placed on the website. For more info check our privacy policy where you will get more info on where, how and why we store your data.

Advertisment ad adsense adlogger