Functional objects

It is obvious when you think about it but functions are objects in JavaScript. So a function can have members. e.g.
var f = function()
{
    return 2;
}

f.g = function(x)
{
    return x + f();
}

If I ran f.g(5); I’d get back 7.

Viewing 1 Comment

 

Trackbacks

(Trackback URL)

close Reblog this comment
blog comments powered by Disqus