views:

338

answers:

2

What is the right/mest way to extend a javascript class so Class B inherits everything from the class A (class B extends A)?

+2  A: 

Take a look at Simple JavaScript Inheritance and Inheritance Patterns in JavaScript.

The simplest method is probably functional inheritance but there are pros and cons.

cletus
+2  A: 

Douglas Crockford has some very good explanations of inheritance in JavaScript:

  1. prototypal inheritance: the 'natural' way to do things in JavaScript
  2. classical inheritance: closer to what you find in most OO languages, but kind of runs against the grain of JavaScript
Annabelle