Reputation: 8101
I did
var x = function (axis) {
return 5;
};
alert(x);
and for output I got not 5, but
function (axis) {
return 5;
};
what am I doing wrong?
Upvotes: 0
Views: 25
Reputation: 8285
Try calling syntax:
<function_name>(<arguments>)
, so in your case:
x()
or:
alert(x())
to display the output.
Upvotes: 4
Reputation: 68400
If you use x
as parameter you're not executing the function and passing the result but passing the function itself.
To execute a function you need to add ()
at the end. So your first example should be
alert(x());
Upvotes: 4