design patterns in javascript