Javascript extends class

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

+57
javascript extends
Feb 13 '10 at 0:50
source share
3 answers

Take a look at Simple JavaScript Inheritance and JavaScript Template Inheritance .

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

+56
Feb 13 '10 at 0:57
source share

Douglas Crockford has very good explanations for JavaScript inheritance:

+28
Feb 13 '10 at 1:09
source share
extend = function(destination, source) { for (var property in source) { destination[property] = source[property]; } return destination; }; 

JavaScript extension

You can also add filters to the for loop.

+2
Oct 28
source share



All Articles