Builder-function based object inheritance chain.
Some sweet object definition, inheritance and instantiation in functional syntax.
var subject = require'subject';// define person buildervar person = subjectdefine// This will be called on instantiationthisname = dataname;// These are simple methods and prototype properties.return 'My name is ' + thisname//;// instantiate personvar joe = person name: 'Joe Smith' ;joeintroduceSelf // My name is Joe Smith// define musician builder, which should inherit from personvar musician = persondefine// Overwrite initialization// call the person'spersonbaseinitializeapplythis arguments;thisinstruments = datainstrments;return _containsthisinstruments instrument ? '♬ ♫ ♪ ♩ ♭ La La La' : 'I can\'t play that!';;// instantiate musicianvar bob = musician name: 'Bob Dylan' instruments: 'guitar' 'voice' 'harmonica' ;// person methodsbobintroduceSelf // My name is Bob Dylan// musician methods.bobplay'harmonica' // ♬ ♫ ♪ ♩ ♭ La La Labobplay'trumpet' // I can't play that!