Upgrade to Pro — share decks privately, control downloads, hide ads and more …

JavaScript Inheritance

Lean Machine
September 04, 2013

JavaScript Inheritance

Lean Machine

September 04, 2013
Tweet

More Decks by Lean Machine

Other Decks in Programming

Transcript

  1. f.say()  //  "meow  says  figaro" s.say()  //  "meow  says  simba"

    p.say()  //  "woof  says  pluto" f.yell()  //  "MEOW  SAYS  FIGARO" s.yell()  //  "MEOW  SAYS  SIMBA" p.yell()  //  "WOOF  SAYS  PLUTO"
  2. var  create  =  function(parent)  {    var  newObj  =  {};

       newObj.__proto__  =  parent;    return  newObj; };
  3. "I have been writing JavaScript for 8 years now (...).

    The super idea is fairly important in the classical pattern, but it appears to be unnecessary in the prototypal and functional patterns. I now see my early attempts to support the classical model in JavaScript as a mistake." http://www.crockford.com/javascript/inheritance.html