Why function called by function name not working when function is created by assigning it to a variable? [duplicate]
// I created two function in JavaScript
// **Function 1**
function add(a, b) {
return a + b;
}
// To call above function I use and it worked as expected
add(2, 3);
// **Function 2**
let x = function mul(a, b) {
return a * b;
}
// To call above function I use two ways
x(2, 3);
mul(2, 3); // This won't work. Why?
Why the mul(2,3); throwing an error?
mul(2,3) is the name of the function, it should be used to call the function.
Via Active questions tagged javascript - Stack Overflow https://ift.tt/2FdjaAW
Comments
Post a Comment