Function in JavaScript

Let's see, How many ways we can declare function in JavaScript

Table of contents

No heading

No headings in the article.

//1. Named function declaration
function namedFunction() {
  console.log("This is a named function");
}


//2. Anonymous function expression
const anonymousFunction = function() {
  console.log("This is an anonymous function");
};


//3. Arrow function expression
const arrowFunction = () => {
  console.log("This is an arrow function");
};


//4. Immediately Invoked Function Expression (IIFE)
(function() {
  console.log("This is an immediately invoked function expression");
})();