Class-based inheritance in JavaScript