Skip to content

Instantly share code, notes, and snippets.

@prashcr
prashcr / gist:5a5a4dad654ad16adb63
Created May 15, 2015 14:50
Inheritance in JavaScript
var d1, d2, d3, d4
function Base() {this.foo = 'foo'}
Base.prototype.bar = 'bar'
// Superconstructor
function D1() {Base.call(this)}
// Set prototype to instance
function D2() { }
D2.prototype = new Base()
// Set prototype to Base.prototype