Functions in JavaScript are really different from many other languages as they are first-class citizens. What this means is that they are treated like any other data type, including objects (actually they are objects), and as such functions can possess properties and even functions, can be assigned to variables, and can be passed to other as an argument. In addition, they can be executed which is really what make functions different from other objects.

Memoization (no typo here) is a technique that takes advantage of the possibility to add properties to functions in order to improve its performance. The following articles covers what memoization is and how to use memoization in JavaScript:

http://addyosmani.com/blog/faster-javascript-memoization/
http://www.sitepoint.com/implementing-memoization-in-javascript/

Trick of the day: Memoization in JavaScript
Tagged on: