In Javascript and in many other languages functions are "first class objects" and this means that you can call/execute a function but you can also store the function in a variable or in an array, or you can pass a function to another function.
Note that I'm not talking about passing the value resulting from calling a function... but the function itself. Consider:
function test10(f) {
for (var i=0; i<10; i++)
alert(f(i));
}
function square(x) { return x*x*; }
function cube(x) { return x*x*x; }
test10(square);
test10(cube);
The last two lines are passing a function (square and cube) as a parameter to function test10.
The () syntax tells Javascript that you want to make the call, and can be used not only with function names, but with any expression like variables or array elements... for example:
var f_arr = [square, cube];
for (var i=0; i<2; i++)
alert(f_arr[i](i+42)); // Will call square(42) and cube(43)
Actually in Javascript the code
function square(x) {
return x * x;
}
is not identical but similar to
square = function(x) {
return x * x;
};
so defining a function is indeed close to assigning a variable