PonchoX

07-03-2011, 11:53 PM

hi.

i know a little php, but new to javascript. much of the syntax is identical.

in reading the new rhino book (flanagan 6th), he gives the following example:

var square = function(x) {

return x*x;

};

okay, but then he does this:

square(plus1(y))

as an example of "invoking two functions in one expresson".

(Prior he gives an example of defining a function with plus1, which is how I normally think of functions.)

uh, square is a *variable*, but he is using it as a FUNCTION.

Can somebody help me understand how this can be? how it works?

I'm having trouble conceptualizng how we use a variable as a function.

i know a little php, but new to javascript. much of the syntax is identical.

in reading the new rhino book (flanagan 6th), he gives the following example:

var square = function(x) {

return x*x;

};

okay, but then he does this:

square(plus1(y))

as an example of "invoking two functions in one expresson".

(Prior he gives an example of defining a function with plus1, which is how I normally think of functions.)

uh, square is a *variable*, but he is using it as a FUNCTION.

Can somebody help me understand how this can be? how it works?

I'm having trouble conceptualizng how we use a variable as a function.