Adding class-like inheritance functionality to objects in javascript