javascript design pattern study