Define anonymous function in JavaScript
Answers (1)
Add AnswerIt 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... } )();