a pattern for javascript classes