+ 4
Can you assign an anonymous function to a variable and pass it as an argument to another function?
var x = function() { return 'It is anonymous function'; };
5 Respostas
+ 3
Why don't you just try it. Make a couple of simple functions. Pass 1 to the other and call the passed function within the body of the second.
+ 3
That's not passing the function x to the function normale, but passing the return value of x to the function normale.
Try,
let x = function() {
return "It's an anonymous function";
};
function normale(func) {
console.log(func());
}
normale(x);
+ 2
Ok thanks ChaoticDawg
+ 1
Yup
+ 1
Like this?
var x = function() {
return 'It is anonymous function';
};
var y = x();
console.log(y);
function normale(y) {
return y;
}
console.log(normale(y));