DEV Community

Cover image for First-Class Function interview question
Nikhil Bobade
Nikhil Bobade

Posted on

First-Class Function interview question

Why we use the first-class function that really needed in JavaScript.

1.A simple definition of the first-class function is a function that can be passed as an argument to another function.

2.And also returned by another function in JavaScript.

3.or also can be assigned the variable to function.

Some Example with the first-class function:-

function with a variable

const foo = function() {
// Invoke it using the variable
Enter fullscreen mode Exit fullscreen mode

A returned a function using the first-class function

function sayHello() {
   return function() {
Enter fullscreen mode Exit fullscreen mode

Thank you!

Top comments (0)