Define anonymous function in JavaScript

Forums JavaScriptDefine anonymous function in JavaScript
Staff asked 3 years ago

Answers (1)

Add Answer
Staff answered 2 years ago

It is a function that is not known by any name. To define a function in JavaScript, we typically use the function keyword followed by the function name; however, for anonymous functions, we just use the function keyword.

Syntax: 

The syntax example that follows shows how to declare an anonymous function using the standard declaration:

function() {
    // Function Body
 }

Alternatively, we may use the arrow function approach, as demonstrated below, to declare an anonymous function:

( () => {
    // Function Body...
} )();

 

Subscribe

Select Categories