Various javascript design patterns