Discussion Forum | Board Infinity

Can an anonymous function be assigned to a variable?

Can an anonymous function be assigned to a variable?

Yes, you can.

Ex:-

const add = (a, b) => { //this is an arrow function
reurn a +b;
};
add(4, 5); // you can call the function using the variable name