Memoization Pattern

From 'JavaScript Patterns' (O'Reilly) by Stoyan Stefanov.