Javascript design patterns memo