Javascript class inheritance implementation