« Back to home

JavaScript function syntax revisited

A commenter pointed out that my previous posting on function in JavaScript missed out some subtle differences between function as a way to create lambdas which are assigned to variables, and function as a statement which creates a function variable. The function statement actually has one benefit: Functions defined using it are lifted to the top of the context which contains them. This means you can refer to them before you define them.…

Read more »

JavaScript: When is a function not a function?

Something that often confuses people new to JavaScript is the use of the function keyword. That’s because it represents two completely different operations, both called function. First of all, there’s the lambda operator “function”. It works exactly like (lambda) in Scheme, {|| } in Ruby, or λ in lambda calculus. That is, it binds one or more arguments to an expression to be evaluated, forming what’s often referred to as a closure.…

Read more »