Now, I usually call a function (that requires no arguments) with ()
like this:
myFunction(); //there\'s empty parens
Except in
First of all, "()" is not part of the function name. It is syntax used to make function calls.
First, you bind a function to an identifier name by either using a function declaration:
function x() {
return "blah";
}
... or by using a function expression:
var x = function() {
return "blah";
};
Now, whenever you want to run this function, you use the parens:
x();
The setTimeout function accepts both and identifier to a function, or a string as the first argument...
setTimeout(x, 1000);
setTimeout("x()", 1000);
If you supply an identifier, then it will get called as a function. If you supply an string, than it will be evaluated (executed).
The first method (supplying an identifier) is preferred ...