JavaScript implementation of common design patterns in programming