Classic design patterns in Javascript