{}
{}  1nelm.io  trueundefined  null
{}
new Object();
{}// v.s.new Object();
(function (){    var Object = function () {        this.changed = true;    }    console.log(new Object());}());// {changed...
(function (){    var Object = function () {        this.changed = true;    }    console.log(new Object());}());// {changed...
(function (){    var Object = function () {        this.changed = true;    }    console.log(new Object());}());// {changed...
(function (){    var Object = function () {        this.changed = true;    }    console.log(new Object());}());// {changed...
(function (){    var Object = function () {        this.changed = true;    }    console.log(new Object());}());// {changed...
(function (){    var Object = function () {        this.changed = true;    }    console.log(new Object());}());// {changed...
{}new Object();
var o = new Object(1);console.log(o.constructor);// function Number() { }// new Number(1);
var o = new Object(1);console.log(o.constructor);// function String() { }// new String(1);
var o = new Object(true);console.log(o.constructor);// function Boolean() { }// new Boolean(true);
var a = {};var b = new Object();var c = Object();
var a = {};var b = new Object();var c = Object();
var a = {};var b = new Object();var c = Object();
new
new Object();
var Car, myCar;Car = function (brand) {    this.brand = brand;};myCar = new Car(Fiat);// {brand: Fiat}
var Car, myCar;Car = function (brand) {    this.brand = brand;};myCar = new Car(Fiat);// {brand: Fiat}
var Car, myCar;Car = function (brand) {    this.brand = brand;};myCar = new Car(Fiat);// {brand: Fiat}
var Car, myCar;Car = function (brand) {    this.brand = brand;};myCar = new Car(Fiat);// {brand: Fiat}
var Car, myCar;Car = function (brand) {    this.brand = brand;};myCar =        Car(Fiat);// undefined
var Car, myCar;Car = function (brand) {    this.brand = brand;};myCar =        Car(Fiat);// undefined
var Car, myCar;Car = function (brand) {    this.brand = brand;};myCar = new Car(Fiat);// {brand: Fiat}
var Car, myCar;Car = function (brand) {    this.brand = brand;};myCar = new Car(Fiat);// {brand: Fiat}
var Car, myCar;Car = function (brand) {    this.brand = brand;    console.log(        this.constructor === Car    );    //...
var Car, myCar;Car = function (brand) {    this.brand = brand;    console.log(        this.constructor === Car    );    //...
var Car, myCar;Car = function (brand) {    if (this.constructor !== Car) {        return new Car(brand);    }    this.bran...
var Car, myCar;Car = function (brand) {    if (this.constructor !== Car) {        return new Car(brand);    }    this.bran...
prototype
{}prototype
var C = function () {};console.log(C.prototype);{    constructor: C,    __proto__: Object.prototype}
var C = function () {};console.log(C.prototype);{    constructor: C,    __proto__: Object.prototype}
var C = function () {};console.log(C.prototype);{    constructor: C,    __proto__: Object.prototype}
var C = function () {};console.log(C.prototype);{    constructor: C,    __proto__: Object.prototype}
var C = function () {};console.log(C.prototype);{    constructor: C,    __proto__: Object.prototype}
var C = function () {};C.prototype = {   a: "A",   b: "B",   constructor: C};console.log(C.prototype);{    a: "A",    b: "...
var C = function () {};C.prototype = {   a: "A",   b: "B",   constructor: C};console.log(C.prototype);{    a: "A",    b: "...
var C = function () {};C.prototype = {   a: "A",   b: "B",   constructor: C // !!!};console.log(C.prototype);{    a: "A", ...
var C = function () {};C.prototype = {   a: "A",   b: "B",   constructor: C};console.log(C.prototype);{    a: "A",    b: "...
var C = function () {};C.prototype = {   a: "A",   b: "B",   constructor: C};console.log(C.prototype);{    a: "A",    b: "...
var C = function () {};C.prototype = {   a: "A",   b: "B",   constructor: C};console.log(C.prototype);{    a: "A",    b: "...
var C = function () {};C.prototype = {   a: "A",   b: "B",   constructor: C};console.log(C.prototype);{    a: "A",    b: "...
var C = function () {};C.prototype.a = "A";C.prototype.b = "B";console.log(C.prototype);{    a: "A",    b: "B",    constru...
var C = function () {};C.prototype.a = "A";C.prototype.b = "B";console.log(C.prototype);{    a: "A",    b: "B",    constru...
{}prototype
property  v.s.attribute
var Car, myCar;Car = function (brand) {    this.brand = brand;};myCar = new Car(Fiat);Car.prototype; // { /* ... */ }myCar...
var Car, myCar;Car = function (brand) {    this.brand = brand;};myCar = new Car(Fiat);Car.prototype; // { /* ... */ }myCar...
var Car, myCar;Car = function (brand) {    this.brand = brand;};myCar = new Car(Fiat);Car.prototype; // { /* ... */ }myCar...
var Car, myCar;Car = function (brand) {    this.brand = brand;};myCar = new Car(Fiat);Car.prototype; // { /* ... */ }myCar...
var Car, myCar;Car = function (brand) {    this.brand = brand;};myCar = new Car(Fiat);Car.prototype; // { /* ... */ }myCar...
var Car, myCar;Car = function (brand) {    this.brand = brand;};myCar = new Car(Fiat);Car.prototype; // { /* ... */ }myCar...
property  v.s.attribute
var Car, myCar;Car = function (brand) {    this.brand = brand;};Car.prototype.getBrand = function () {    return this.bran...
var Car, myCar;Car = function (brand) {    this.brand = brand;};Car.prototype.getBrand = function () {    return this.bran...
var Car, myCar;Car = function (brand) {    this.brand = brand;};Car.prototype.getBrand = function () {    return this.bran...
var Car, myCar;Car = function (brand) {    this.brand = brand;};Car.prototype.getBrand = function () {    return this.bran...
var Car, myCar;Car = function (brand) {    this.brand = brand;};Car.prototype.getBrand = function () {    return this.bran...
var Car, myCar;Car = function (brand) {    this.brand = brand;};Car.prototype.getBrand = function () {    return this.bran...
var Car, myCar;Car = function (brand) {    this.brand = brand;};Car.prototype.getBrand = function () {    return this.bran...
{}prototype
inheritance
classicalinheritance  modern
classicalinheritance
var Car, ItalianCar, myCar;Car = function (brand) {  this.brand = brand || Homemade;}Car.prototype.getBrand = function () ...
var Car, ItalianCar, myCar;Car = function (brand) {  this.brand = brand || Homemade;}Car.prototype.getBrand = function () ...
var Car, ItalianCar, myCar;Car = function (brand) {  this.brand = brand || Homemade;}Car.prototype.getBrand = function () ...
var Car, ItalianCar, myCar;Car = function (brand) {  this.brand = brand || Homemade;}Car.prototype.getBrand = function () ...
var Car, ItalianCar, myCar;Car = function (brand) {  this.brand = brand || Homemade;}Car.prototype.getBrand = function () ...
var Car, ItalianCar, myCar;Car = function (brand) {  this.brand = brand || Homemade;}Car.prototype.getBrand = function () ...
var Car, ItalianCar, myCar;Car = function (brand) {  this.brand = brand || Homemade;}Car.prototype.getBrand = function () ...
classical inheritance1.   Default Pattern2.   Rent-a-Constructor3.   Rent and Set Prototype4.   Share Prototype5.   Temp. ...
classical inheritance1.   Default Pattern2.   Rent-a-Constructor3.   Rent and Set Prototype4.   Share Prototype5.   Temp. ...
var inherit = function (Child, Parent) {  Child.prototype = new Parent();}
var inherit = function (Child, Parent) {  Child.prototype = new Parent();}myCar = new ItalianCar();myCar.getBrand();// Hom...
var inherit = function (Child, Parent) {  Child.prototype = new Parent();}myCar = new ItalianCar();myCar.getBrand();// Hom...
var inherit = function (Child, Parent) {  Child.prototype = new Parent();}myCar = new ItalianCar();myCar.getBrand();// Hom...
var inherit = function (Child, Parent) {  Child.prototype = new Parent();}myCar = new ItalianCar();myCar.getBrand();// Hom...
myCar.brand = "Fiat";myCar.getBrand(); // Fiat
myCar.getBrand();// Fiat
myCar = new ItalianCar();myCar.brand = Fiat;
myCar = new ItalianCar(Fiat)
myCar = new ItalianCar(Fiat)myCar.getBrand(); // Homemade
var Car, ItalianCar, myCar;Car = function (brand) {  this.brand = brand || Homemade;}Car.prototype.getBrand = function () ...
classical inheritance1.   Default Pattern2.   Rent-a-Constructor3.   Rent and Set Prototype4.   Share Prototype5.   Temp. ...
ItalianCar = function (brand) {  Car.apply(this, [brand]);}
var Car, ItalianCar, myCar;Car = function (brand) {  this.brand = brand || Homemade;}Car.prototype.getBrand = function () ...
var Car, ItalianCar, myCar;Car = function (brand) {  this.brand = brand || Homemade;}Car.prototype.getBrand = function () ...
var Car, ItalianCar, myCar;Car = function (brand) {  this.brand = brand || Homemade;}Car.prototype.getBrand = function () ...
var Car, ItalianCar, myCar;Car = function (brand) {  this.brand = brand || Homemade;}Car.prototype.getBrand = function () ...
var Car, ItalianCar, myCar;Car = function (brand) {  this.brand = brand || Homemade;}Car.prototype.getBrand = function () ...
var Car, ItalianCar, myCar;Car = function (brand) {  this.brand = brand || Homemade;}Car.prototype.getBrand = function () ...
var Car, ItalianCar, myCar;Car = function (brand) {  this.brand = brand || Homemade;}Car.prototype.getBrand = function () ...
var Car, ItalianCar, myCar;Car = function (brand) {  this.brand = brand || Homemade;}Car.prototype.getBrand = function () ...
classical inheritance1.   Default Pattern2.   Rent-a-Constructor3.   Rent and Set Prototype4.   Share Prototype5.   Temp. ...
ItalianCar = function (brand) {  Car.apply(this, [brand]);}ItalianCar.prototype = new Car();
ItalianCar = function (brand) {  Car.apply(this, [brand]);}ItalianCar.prototype = new Car();
ItalianCar = function (brand) {  Car.apply(this, [brand]);}ItalianCar.prototype = new Car();
ItalianCar = function (brand) {  Car.apply(this, [brand]);}ItalianCar.prototype = new Car();
var Car, ItalianCar, myCar;Car = function (brand) {  this.brand = brand || Homemade;}Car.prototype.getBrand = function () ...
var Car, ItalianCar, myCar;Car = function (brand) {  this.brand = brand || Homemade;}Car.prototype.getBrand = function () ...
var Car, ItalianCar, myCar;Car = function (brand) {  this.brand = brand || Homemade;}Car.prototype.getBrand = function () ...
var Car, ItalianCar, myCar;Car = function (brand) {  this.brand = brand || Homemade;}Car.prototype.getBrand = function () ...
var Car, ItalianCar, myCar;Car = function (brand) {  this.brand = brand || Homemade;}Car.prototype.getBrand = function () ...
var Car, ItalianCar, myCar;Car = function (brand) {  this.brand = brand || Homemade;}Car.prototype.getBrand = function () ...
var Car, ItalianCar, myCar;Car = function (brand) {  this.brand = brand || Homemade;}Car.prototype.getBrand = function () ...
var Car, ItalianCar, myCar;Car = function (brand) {  this.brand = brand || Homemade;}Car.prototype.getBrand = function () ...
var Car, ItalianCar, myCar;Car = function (brand) {  this.brand = brand || Homemade;}Car.prototype.getBrand = function () ...
var Car, ItalianCar, myCar;Car = function (brand) {  this.brand = brand || Homemade;}Car.prototype.getBrand = function () ...
classical inheritance1.   Default Pattern2.   Rent-a-Constructor3.   Rent and Set Prototype4.   Share Prototype5.   Temp. ...
var inherit = function (Child, Parent) {  Child.prototype = Parent.prototype;}
classical inheritance1.   Default Pattern2.   Rent-a-Constructor3.   Rent and Set Prototype4.   Share Prototype5.   Temp. ...
var inherit = function (Child, Parent) {  var F = function () {};  F.prototype = Parent.prototype;  Child.prototype = new ...
var inherit = function (Child, Parent) {  var F = function () {};  F.prototype = Parent.prototype;  Child.prototype = new ...
var inherit = function (Child, Parent) {  var F = function () {};  F.prototype = Parent.prototype;  Child.prototype = new ...
var inherit = function (Child, Parent) {  var F = function () {};  F.prototype = Parent.prototype;  Child.prototype = new ...
var inherit = function (Child, Parent) {  var F = function () {};  F.prototype = Parent.prototype;  Child.prototype = new ...
inherit(ItalianCar, Car);myCar = new ItalianCar();myCar.brand;    // undefinedmyCar.getBrand; // function
inherit(ItalianCar, Car);myCar = new ItalianCar();myCar.brand;    // undefinedmyCar.getBrand; // function
inherit(ItalianCar, Car);myCar = new ItalianCar();myCar.brand;    // undefinedmyCar.getBrand; // function
inherit(ItalianCar, Car);myCar = new ItalianCar();myCar.brand;    // undefinedmyCar.getBrand; // function
inherit(ItalianCar, Car);myCar = new ItalianCar();myCar.brand;    // undefinedmyCar.getBrand; // function
inherit(ItalianCar, Car);myCar = new ItalianCar();myCar.brand;    // undefinedmyCar.getBrand; // function
var inherit = function (Child, Parent) {  var F = function () {};  F.prototype = Parent.prototype;  Child.prototype = new ...
var inherit = function (Child, Parent) {  var F = function () {};  F.prototype = Parent.prototype;  Child.prototype = new ...
var inherit = function (Child, Parent) {  var F = function () {};  F.prototype = Parent.prototype;  Child.prototype = new ...
var inherit = function (Child, Parent) {  var F = function () {};  F.prototype = Parent.prototype;  Child.prototype = new ...
classical inheritance1.   Default Pattern2.   Rent-a-Constructor3.   Rent and Set Prototype4.   Share Prototype5.   Temp. ...
classical inheritance1.   Default Patternklass2.   Rent-a-Constructor3.   Rent and Set Prototype4.   Share Prototype5.   T...
var Parent = klass(   null,   {     __construct: function () {},     someMethod: function () {}   });var Child = klass(   ...
var Parent = klass(   null,   {     __construct: function () {},     someMethod: function () {}   });var Child = klass(   ...
var Parent = klass(   null,   {     __construct: function () {},     someMethod: function () {}   });var Child = klass(   ...
var Parent = klass(   null,   {     __construct: function () {},     someMethod: function () {}   });var Child = klass(   ...
var Parent = klass(   null,   {     __construct: function () {},     someMethod: function () {}   });var Child = klass(   ...
var Parent = klass(   null,   {     __construct: function () {},     someMethod: function () {}   });var Child = klass(   ...
var Parent = klass(   null,   {     __construct: function () {},     someMethod: function () {}   });var Child = klass(   ...
var Man = klass(   null,   {     __construct: function (what) {        console.log(man constructor);        this.name = wh...
var Man = klass(   null,   {     __construct: function (what) {        console.log(man constructor);        this.name = wh...
var Man = klass(   null,   {     __construct: function (what) {        console.log(man constructor);        this.name = wh...
var Man = klass(   null,   {     __construct: function (what) {        console.log(man constructor);        this.name = wh...
var Man = klass(   null,   {     __construct: function (what) {        console.log(man constructor);        this.name = wh...
var Man = klass(   null,   {     __construct: function (what) {        console.log(man constructor);        this.name = wh...
var Man = klass(   null,   {     __construct: function (what) {        console.log(man constructor);        this.name = wh...
var first = new Man(Adam);// logs man constructorfirst.getName();// Adam
var first = new Man(Adam);// logs man constructorfirst.getName();// Adam
var first = new Man(Adam);// logs man constructorfirst.getName();// Adam
var first = new Man(Adam);// logs man constructorfirst.getName();// Adam
var SuperMan = klass(   Man,   {     __construct: function (what) {        console.log(super man constructor);     },     ...
var SuperMan = klass(   Man,   {     __construct: function (what) {        console.log(super man constructor);     },     ...
var SuperMan = klass(   Man,   {     __construct: function (what) {        console.log(super man constructor);     },     ...
var SuperMan = klass(   Man,   {     __construct: function (what) {        console.log(super man constructor);     },     ...
var SuperMan = klass(   Man,   {     __construct: function (what) {        console.log(super man constructor);     },     ...
var SuperMan = klass(   Man,   {     __construct: function (what) {        console.log(super man constructor);     },     ...
var SuperMan = klass(   Man,   {     __construct: function (what) {        console.log(super man constructor);     },     ...
var clark = new SuperMan(Clark Kent);// logs man constructor// and super man constructorclark.getName();// I am Clark Kent
var clark = new SuperMan(Clark Kent);// logs man constructor// and super man constructorclark.getName();// I am Clark Kent
var clark = new SuperMan(Clark Kent);// logs man constructor// and super man constructorclark.getName();// I am Clark Kent
var clark = new SuperMan(Clark Kent);// logs man constructor// and super man constructorclark.getName();// I am Clark Kent
var clark = new SuperMan(Clark Kent);// logs man constructor// and super man constructorclark.getName();// I am Clark Kent
var klass = function (Parent, props) {  var Child, F, i;     Child = function () {        if (Child.uber && Child.uber.has...
var klass = function (Parent, props) {  var Child, F, i;     Child = function () {        if (Child.uber && Child.uber.has...
var klass = function (Parent, props) {  var Child, F, i;     Child = function () {        if (Child.uber && Child.uber.has...
var klass = function (Parent, props) {  var Child, F, i;     Child = function () {        if (Child.uber && Child.uber.has...
var klass = function (Parent, props) {  var Child, F, i;     Child = function () {        if (Child.uber && Child.uber.has...
Child = function () {   if (Child.uber && Child.uber.hasOwnProperty(__construct)) {     Child.uber.__construct.apply(this,...
Child = function () {   if (Child.uber && Child.uber.hasOwnProperty(__construct)) {     Child.uber.__construct.apply(this,...
Child = function () {   if (Child.uber && Child.uber.hasOwnProperty(__construct)) {     Child.uber.__construct.apply(this,...
Child = function () {   if (Child.uber && Child.uber.hasOwnProperty(__construct)) {     Child.uber.__construct.apply(this,...
Child = function () {   if (Child.uber && Child.uber.hasOwnProperty(__construct)) {     Child.uber.__construct.apply(this,...
Parent = Parent || Object;F = function () {};F.prototype = Parent.prototype;Child.prototype = new F();Child.uber = Parent....
Parent = Parent || Object;F = function () {};F.prototype = Parent.prototype;Child.prototype = new F();Child.uber = Parent....
Parent = Parent || Object;F = function () {};F.prototype = Parent.prototype;Child.prototype = new F();Child.uber = Parent....
Parent = Parent || Object;F = function () {};F.prototype = Parent.prototype;Child.prototype = new F();Child.uber = Parent....
Parent = Parent || Object;F = function () {};F.prototype = Parent.prototype;Child.prototype = new F();Child.uber = Parent....
Parent = Parent || Object;F = function () {};F.prototype = Parent.prototype;Child.prototype = new F();Child.uber = Parent....
var klass = function (Parent, props) {     /* ... */     for (i in props) {       if (props.hasOwnProperty(i)) {         C...
var klass = function (Parent, props) {     /* ... */     for (i in props) {       if (props.hasOwnProperty(i)) {         C...
var klass = function (Parent, props) {     /* ... */     for (i in props) {       if (props.hasOwnProperty(i)) {         C...
var klass = function (Parent, props) {     /* ... */     for (i in props) {       if (props.hasOwnProperty(i)) {         C...
var klass = function (Parent, props) {     /* ... */     for (i in props) {       if (props.hasOwnProperty(i)) {         C...
var klass = function (Parent, props) {     /* ... */     for (i in props) {       if (props.hasOwnProperty(i)) {         C...
var klass = function (Parent, props) {  var Child, F, i;     Child = function () {        if (Child.uber && Child.uber.has...
X
Oop in java script
Oop in java script
Oop in java script
Oop in java script
Oop in java script
Oop in java script
Oop in java script
Oop in java script
Oop in java script
Oop in java script
Oop in java script
Oop in java script
Upcoming SlideShare
Loading in …5
×

Oop in java script

2,759 views

Published on

Presentation on Classical Inheritance Patterns in JavaScript.

Published in: Technology, Business
0 Comments
10 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
2,759
On SlideShare
0
From Embeds
0
Number of Embeds
3
Actions
Shares
0
Downloads
90
Comments
0
Likes
10
Embeds 0
No embeds

No notes for slide

Oop in java script

  1. 1. {}
  2. 2. {} 1nelm.io trueundefined null
  3. 3. {}
  4. 4. new Object();
  5. 5. {}// v.s.new Object();
  6. 6. (function (){ var Object = function () { this.changed = true; } console.log(new Object());}());// {changed: true}
  7. 7. (function (){ var Object = function () { this.changed = true; } console.log(new Object());}());// {changed: true}
  8. 8. (function (){ var Object = function () { this.changed = true; } console.log(new Object());}());// {changed: true}
  9. 9. (function (){ var Object = function () { this.changed = true; } console.log(new Object());}());// {changed: true}
  10. 10. (function (){ var Object = function () { this.changed = true; } console.log(new Object());}());// {changed: true}
  11. 11. (function (){ var Object = function () { this.changed = true; } console.log(new Object());}());// {changed: true}
  12. 12. {}new Object();
  13. 13. var o = new Object(1);console.log(o.constructor);// function Number() { }// new Number(1);
  14. 14. var o = new Object(1);console.log(o.constructor);// function String() { }// new String(1);
  15. 15. var o = new Object(true);console.log(o.constructor);// function Boolean() { }// new Boolean(true);
  16. 16. var a = {};var b = new Object();var c = Object();
  17. 17. var a = {};var b = new Object();var c = Object();
  18. 18. var a = {};var b = new Object();var c = Object();
  19. 19. new
  20. 20. new Object();
  21. 21. var Car, myCar;Car = function (brand) { this.brand = brand;};myCar = new Car(Fiat);// {brand: Fiat}
  22. 22. var Car, myCar;Car = function (brand) { this.brand = brand;};myCar = new Car(Fiat);// {brand: Fiat}
  23. 23. var Car, myCar;Car = function (brand) { this.brand = brand;};myCar = new Car(Fiat);// {brand: Fiat}
  24. 24. var Car, myCar;Car = function (brand) { this.brand = brand;};myCar = new Car(Fiat);// {brand: Fiat}
  25. 25. var Car, myCar;Car = function (brand) { this.brand = brand;};myCar = Car(Fiat);// undefined
  26. 26. var Car, myCar;Car = function (brand) { this.brand = brand;};myCar = Car(Fiat);// undefined
  27. 27. var Car, myCar;Car = function (brand) { this.brand = brand;};myCar = new Car(Fiat);// {brand: Fiat}
  28. 28. var Car, myCar;Car = function (brand) { this.brand = brand;};myCar = new Car(Fiat);// {brand: Fiat}
  29. 29. var Car, myCar;Car = function (brand) { this.brand = brand; console.log( this.constructor === Car ); // true};myCar = new Car(Fiat);
  30. 30. var Car, myCar;Car = function (brand) { this.brand = brand; console.log( this.constructor === Car ); // undefined};myCar = Car(Fiat);
  31. 31. var Car, myCar;Car = function (brand) { if (this.constructor !== Car) { return new Car(brand); } this.brand = brand;};myCar = Car(Fiat);
  32. 32. var Car, myCar;Car = function (brand) { if (this.constructor !== Car) { return new Car(brand); } this.brand = brand;};myCar = new Car(Fiat);
  33. 33. prototype
  34. 34. {}prototype
  35. 35. var C = function () {};console.log(C.prototype);{ constructor: C, __proto__: Object.prototype}
  36. 36. var C = function () {};console.log(C.prototype);{ constructor: C, __proto__: Object.prototype}
  37. 37. var C = function () {};console.log(C.prototype);{ constructor: C, __proto__: Object.prototype}
  38. 38. var C = function () {};console.log(C.prototype);{ constructor: C, __proto__: Object.prototype}
  39. 39. var C = function () {};console.log(C.prototype);{ constructor: C, __proto__: Object.prototype}
  40. 40. var C = function () {};C.prototype = { a: "A", b: "B", constructor: C};console.log(C.prototype);{ a: "A", b: "B", constructor: C, __proto__: Object.prototype}
  41. 41. var C = function () {};C.prototype = { a: "A", b: "B", constructor: C};console.log(C.prototype);{ a: "A", b: "B", constructor: C, __proto__: Object.prototype}
  42. 42. var C = function () {};C.prototype = { a: "A", b: "B", constructor: C // !!!};console.log(C.prototype);{ a: "A", b: "B", constructor: C, __proto__: Object.prototype}
  43. 43. var C = function () {};C.prototype = { a: "A", b: "B", constructor: C};console.log(C.prototype);{ a: "A", b: "B", constructor: C, __proto__: Object.prototype}
  44. 44. var C = function () {};C.prototype = { a: "A", b: "B", constructor: C};console.log(C.prototype);{ a: "A", b: "B", constructor: C, __proto__: Object.prototype}
  45. 45. var C = function () {};C.prototype = { a: "A", b: "B", constructor: C};console.log(C.prototype);{ a: "A", b: "B", constructor: C, __proto__: Object.prototype}
  46. 46. var C = function () {};C.prototype = { a: "A", b: "B", constructor: C};console.log(C.prototype);{ a: "A", b: "B", constructor: C, __proto__: Object.prototype}
  47. 47. var C = function () {};C.prototype.a = "A";C.prototype.b = "B";console.log(C.prototype);{ a: "A", b: "B", constructor: C, __proto__: Object.prototype}
  48. 48. var C = function () {};C.prototype.a = "A";C.prototype.b = "B";console.log(C.prototype);{ a: "A", b: "B", constructor: C, __proto__: Object.prototype}
  49. 49. {}prototype
  50. 50. property v.s.attribute
  51. 51. var Car, myCar;Car = function (brand) { this.brand = brand;};myCar = new Car(Fiat);Car.prototype; // { /* ... */ }myCar.prototype; // undefined
  52. 52. var Car, myCar;Car = function (brand) { this.brand = brand;};myCar = new Car(Fiat);Car.prototype; // { /* ... */ }myCar.prototype; // undefined
  53. 53. var Car, myCar;Car = function (brand) { this.brand = brand;};myCar = new Car(Fiat);Car.prototype; // { /* ... */ }myCar.prototype; // undefined
  54. 54. var Car, myCar;Car = function (brand) { this.brand = brand;};myCar = new Car(Fiat);Car.prototype; // { /* ... */ }myCar.prototype; // undefined
  55. 55. var Car, myCar;Car = function (brand) { this.brand = brand;};myCar = new Car(Fiat);Car.prototype; // { /* ... */ }myCar.prototype; // undefined
  56. 56. var Car, myCar;Car = function (brand) { this.brand = brand;};myCar = new Car(Fiat);Car.prototype; // { /* ... */ }myCar.prototype; // undefined
  57. 57. property v.s.attribute
  58. 58. var Car, myCar;Car = function (brand) { this.brand = brand;};Car.prototype.getBrand = function () { return this.brand;};myCar = new Car(Fiat);myCar.brand;myCar.getBrand();
  59. 59. var Car, myCar;Car = function (brand) { this.brand = brand;};Car.prototype.getBrand = function () { return this.brand;};myCar = new Car(Fiat);myCar.brand;myCar.getBrand();
  60. 60. var Car, myCar;Car = function (brand) { this.brand = brand;};Car.prototype.getBrand = function () { return this.brand;};myCar = new Car(Fiat);myCar.brand;myCar.getBrand();
  61. 61. var Car, myCar;Car = function (brand) { this.brand = brand;};Car.prototype.getBrand = function () { return this.brand;};myCar = new Car(Fiat);myCar.brand;myCar.getBrand();
  62. 62. var Car, myCar;Car = function (brand) { this.brand = brand;};Car.prototype.getBrand = function () { return this.brand;};myCar = new Car(Fiat);myCar.brand;myCar.getBrand();
  63. 63. var Car, myCar;Car = function (brand) { this.brand = brand;};Car.prototype.getBrand = function () { return this.brand;};myCar = new Car(Fiat);myCar.brand;myCar.getBrand();
  64. 64. var Car, myCar;Car = function (brand) { this.brand = brand;};Car.prototype.getBrand = function () { return this.brand;};myCar = new Car(Fiat);myCar.brand;myCar.getBrand();
  65. 65. {}prototype
  66. 66. inheritance
  67. 67. classicalinheritance modern
  68. 68. classicalinheritance
  69. 69. var Car, ItalianCar, myCar;Car = function (brand) { this.brand = brand || Homemade;}Car.prototype.getBrand = function () { return this.brand;}ItalianCar = function (brand) {};inherit(ItalianCar, Car);myCar = new ItalianCar(Fiat);
  70. 70. var Car, ItalianCar, myCar;Car = function (brand) { this.brand = brand || Homemade;}Car.prototype.getBrand = function () { return this.brand;}ItalianCar = function (brand) {}inherit(ItalianCar, Car);myCar = new ItalianCar(Fiat);
  71. 71. var Car, ItalianCar, myCar;Car = function (brand) { this.brand = brand || Homemade;}Car.prototype.getBrand = function () { return this.brand;}ItalianCar = function (brand) {}inherit(ItalianCar, Car);myCar = new ItalianCar(Fiat);
  72. 72. var Car, ItalianCar, myCar;Car = function (brand) { this.brand = brand || Homemade;}Car.prototype.getBrand = function () { return this.brand;}ItalianCar = function (brand) {};inherit(ItalianCar, Car);myCar = new ItalianCar(Fiat);
  73. 73. var Car, ItalianCar, myCar;Car = function (brand) { this.brand = brand || Homemade;}Car.prototype.getBrand = function () { return this.brand;}ItalianCar = function (brand) {}inherit(ItalianCar, Car);myCar = new ItalianCar(Fiat);
  74. 74. var Car, ItalianCar, myCar;Car = function (brand) { this.brand = brand || Homemade;}Car.prototype.getBrand = function () { return this.brand;}ItalianCar = function (brand) {}inherit(ItalianCar, Car);myCar = new ItalianCar(Fiat);
  75. 75. var Car, ItalianCar, myCar;Car = function (brand) { this.brand = brand || Homemade;}Car.prototype.getBrand = function () { return this.brand;}ItalianCar = function (brand) {};inherit(ItalianCar, Car);myCar = new ItalianCar(Fiat);
  76. 76. classical inheritance1. Default Pattern2. Rent-a-Constructor3. Rent and Set Prototype4. Share Prototype5. Temp. Constructor
  77. 77. classical inheritance1. Default Pattern2. Rent-a-Constructor3. Rent and Set Prototype4. Share Prototype5. Temp. Constructor
  78. 78. var inherit = function (Child, Parent) { Child.prototype = new Parent();}
  79. 79. var inherit = function (Child, Parent) { Child.prototype = new Parent();}myCar = new ItalianCar();myCar.getBrand();// Homemade
  80. 80. var inherit = function (Child, Parent) { Child.prototype = new Parent();}myCar = new ItalianCar();myCar.getBrand();// Homemade
  81. 81. var inherit = function (Child, Parent) { Child.prototype = new Parent();}myCar = new ItalianCar();myCar.getBrand();// Homemade
  82. 82. var inherit = function (Child, Parent) { Child.prototype = new Parent();}myCar = new ItalianCar();myCar.getBrand();// Homemade
  83. 83. myCar.brand = "Fiat";myCar.getBrand(); // Fiat
  84. 84. myCar.getBrand();// Fiat
  85. 85. myCar = new ItalianCar();myCar.brand = Fiat;
  86. 86. myCar = new ItalianCar(Fiat)
  87. 87. myCar = new ItalianCar(Fiat)myCar.getBrand(); // Homemade
  88. 88. var Car, ItalianCar, myCar;Car = function (brand) { this.brand = brand || Homemade;}Car.prototype.getBrand = function () { return this.brand;}ItalianCar = function (brand) {}inherit(ItalianCar, Car);// ItalianCar.prototype = new Car();
  89. 89. classical inheritance1. Default Pattern2. Rent-a-Constructor3. Rent and Set Prototype4. Share Prototype5. Temp. Constructor
  90. 90. ItalianCar = function (brand) { Car.apply(this, [brand]);}
  91. 91. var Car, ItalianCar, myCar;Car = function (brand) { this.brand = brand || Homemade;}Car.prototype.getBrand = function () { return this.brand;}ItalianCar = function (brand) { Car.apply(this, [brand]);}myCar = new ItalianCar(Fiat);myCar.brand; // Fiat;
  92. 92. var Car, ItalianCar, myCar;Car = function (brand) { this.brand = brand || Homemade;}Car.prototype.getBrand = function () { return this.brand;}ItalianCar = function (brand) { Car.apply(this, [brand]);}myCar = new ItalianCar(Fiat);myCar.brand; // Fiat;
  93. 93. var Car, ItalianCar, myCar;Car = function (brand) { this.brand = brand || Homemade;}Car.prototype.getBrand = function () { return this.brand;}ItalianCar = function (brand) { Car.apply(this, [brand]);}myCar = new ItalianCar(Fiat);myCar.brand; // Fiat;
  94. 94. var Car, ItalianCar, myCar;Car = function (brand) { this.brand = brand || Homemade;}Car.prototype.getBrand = function () { return this.brand;}ItalianCar = function (brand) { Car.apply(this, [brand]);}myCar = new ItalianCar(Fiat);myCar.brand; // Fiat;
  95. 95. var Car, ItalianCar, myCar;Car = function (brand) { this.brand = brand || Homemade;}Car.prototype.getBrand = function () { return this.brand;}ItalianCar = function (brand) { Car.apply(this, [brand]);}myCar = new ItalianCar(Fiat);myCar.brand; // Fiat;
  96. 96. var Car, ItalianCar, myCar;Car = function (brand) { this.brand = brand || Homemade;}Car.prototype.getBrand = function () { return this.brand;}ItalianCar = function (brand) { Car.apply(this, [brand]);}myCar = new ItalianCar(Fiat);myCar.brand; // Fiat;myCar.getBrand; // undefined
  97. 97. var Car, ItalianCar, myCar;Car = function (brand) { this.brand = brand || Homemade;}Car.prototype.getBrand = function () { return this.brand;}ItalianCar = function (brand) { Car.apply(this, [brand]);}myCar = new ItalianCar(Fiat);myCar.brand; // Fiat;myCar.getBrand; // undefined
  98. 98. var Car, ItalianCar, myCar;Car = function (brand) { this.brand = brand || Homemade;}Car.prototype.getBrand = function () { return this.brand;}ItalianCar = function (brand) { Car.apply(this, [brand]);}myCar = new ItalianCar(Fiat);myCar.brand; // Fiat;myCar.getBrand; // undefined
  99. 99. classical inheritance1. Default Pattern2. Rent-a-Constructor3. Rent and Set Prototype4. Share Prototype5. Temp. Constructor
  100. 100. ItalianCar = function (brand) { Car.apply(this, [brand]);}ItalianCar.prototype = new Car();
  101. 101. ItalianCar = function (brand) { Car.apply(this, [brand]);}ItalianCar.prototype = new Car();
  102. 102. ItalianCar = function (brand) { Car.apply(this, [brand]);}ItalianCar.prototype = new Car();
  103. 103. ItalianCar = function (brand) { Car.apply(this, [brand]);}ItalianCar.prototype = new Car();
  104. 104. var Car, ItalianCar, myCar;Car = function (brand) { this.brand = brand || Homemade;}Car.prototype.getBrand = function () { return this.brand;}ItalianCar = function (brand) { Car.apply(this, [brand]);}ItalianCar.prototype = new Car();myCar = new ItalianCar(Fiat);myCar.brand; // Fiat;myCar.getBrand(); // Fiatdelete myCar.brand;myCar.getBrand(); // Homemade
  105. 105. var Car, ItalianCar, myCar;Car = function (brand) { this.brand = brand || Homemade;}Car.prototype.getBrand = function () { return this.brand;}ItalianCar = function (brand) { Car.apply(this, [brand]);}ItalianCar.prototype = new Car();myCar = new ItalianCar(Fiat);myCar.brand; // Fiat;myCar.getBrand(); // Fiatdelete myCar.brand;myCar.getBrand(); // Homemade
  106. 106. var Car, ItalianCar, myCar;Car = function (brand) { this.brand = brand || Homemade;}Car.prototype.getBrand = function () { return this.brand;}ItalianCar = function (brand) { Car.apply(this, [brand]);}ItalianCar.prototype = new Car();myCar = new ItalianCar(Fiat);myCar.brand; // Fiat;myCar.getBrand(); // Fiatdelete myCar.brand;myCar.getBrand(); // Homemade
  107. 107. var Car, ItalianCar, myCar;Car = function (brand) { this.brand = brand || Homemade;}Car.prototype.getBrand = function () { return this.brand;}ItalianCar = function (brand) { Car.apply(this, [brand]);}ItalianCar.prototype = new Car();myCar = new ItalianCar(Fiat);myCar.brand; // Fiat;myCar.getBrand(); // Fiatdelete myCar.brand;myCar.getBrand(); // Homemade
  108. 108. var Car, ItalianCar, myCar;Car = function (brand) { this.brand = brand || Homemade;}Car.prototype.getBrand = function () { return this.brand;}ItalianCar = function (brand) { Car.apply(this, [brand]);}ItalianCar.prototype = new Car();myCar = new ItalianCar(Fiat);myCar.brand; // Fiat;myCar.getBrand(); // Fiatdelete myCar.brand;myCar.getBrand(); // Homemade
  109. 109. var Car, ItalianCar, myCar;Car = function (brand) { this.brand = brand || Homemade;}Car.prototype.getBrand = function () { return this.brand;}ItalianCar = function (brand) { Car.apply(this, [brand]);}ItalianCar.prototype = new Car();myCar = new ItalianCar(Fiat);myCar.brand; // Fiat;myCar.getBrand(); // Fiatdelete myCar.brand;myCar.getBrand(); // Homemade
  110. 110. var Car, ItalianCar, myCar;Car = function (brand) { this.brand = brand || Homemade;}Car.prototype.getBrand = function () { return this.brand;}ItalianCar = function (brand) { Car.apply(this, [brand]);}ItalianCar.prototype = new Car();myCar = new ItalianCar(Fiat);myCar.brand; // Fiat;myCar.getBrand(); // Fiatdelete myCar.brand;myCar.getBrand(); // Homemade
  111. 111. var Car, ItalianCar, myCar;Car = function (brand) { this.brand = brand || Homemade;}Car.prototype.getBrand = function () { return this.brand;}ItalianCar = function (brand) { Car.apply(this, [brand]);}ItalianCar.prototype = new Car();myCar = new ItalianCar(Fiat);myCar.brand; // Fiat;myCar.getBrand(); // Fiatdelete myCar.brand;myCar.getBrand(); // Homemade
  112. 112. var Car, ItalianCar, myCar;Car = function (brand) { this.brand = brand || Homemade;}Car.prototype.getBrand = function () { return this.brand;}ItalianCar = function (brand) { Car.apply(this, [brand]);}ItalianCar.prototype = new Car();myCar = new ItalianCar(Fiat);myCar.brand; // Fiat;myCar.getBrand(); // Fiatdelete myCar.brand;myCar.getBrand(); // Homemade
  113. 113. var Car, ItalianCar, myCar;Car = function (brand) { this.brand = brand || Homemade;}Car.prototype.getBrand = function () { return this.brand;}ItalianCar = function (brand) { Car.apply(this, [brand]);}myCar = new ItalianCar(Fiat);myCar.brand; // Fiat;myCar.getBrand; // undefined
  114. 114. classical inheritance1. Default Pattern2. Rent-a-Constructor3. Rent and Set Prototype4. Share Prototype5. Temp. Constructor
  115. 115. var inherit = function (Child, Parent) { Child.prototype = Parent.prototype;}
  116. 116. classical inheritance1. Default Pattern2. Rent-a-Constructor3. Rent and Set Prototype4. Share Prototype5. Temp. Constructor
  117. 117. var inherit = function (Child, Parent) { var F = function () {}; F.prototype = Parent.prototype; Child.prototype = new F();}
  118. 118. var inherit = function (Child, Parent) { var F = function () {}; F.prototype = Parent.prototype; Child.prototype = new F();}
  119. 119. var inherit = function (Child, Parent) { var F = function () {}; F.prototype = Parent.prototype; Child.prototype = new F();}
  120. 120. var inherit = function (Child, Parent) { var F = function () {}; F.prototype = Parent.prototype; Child.prototype = new F();}
  121. 121. var inherit = function (Child, Parent) { var F = function () {}; F.prototype = Parent.prototype; Child.prototype = new F();}
  122. 122. inherit(ItalianCar, Car);myCar = new ItalianCar();myCar.brand; // undefinedmyCar.getBrand; // function
  123. 123. inherit(ItalianCar, Car);myCar = new ItalianCar();myCar.brand; // undefinedmyCar.getBrand; // function
  124. 124. inherit(ItalianCar, Car);myCar = new ItalianCar();myCar.brand; // undefinedmyCar.getBrand; // function
  125. 125. inherit(ItalianCar, Car);myCar = new ItalianCar();myCar.brand; // undefinedmyCar.getBrand; // function
  126. 126. inherit(ItalianCar, Car);myCar = new ItalianCar();myCar.brand; // undefinedmyCar.getBrand; // function
  127. 127. inherit(ItalianCar, Car);myCar = new ItalianCar();myCar.brand; // undefinedmyCar.getBrand; // function
  128. 128. var inherit = function (Child, Parent) { var F = function () {}; F.prototype = Parent.prototype; Child.prototype = new F(); Child.uber = Parent.prototype;}
  129. 129. var inherit = function (Child, Parent) { var F = function () {}; F.prototype = Parent.prototype; Child.prototype = new F(); Child.uber = Parent.prototype;}
  130. 130. var inherit = function (Child, Parent) { var F = function () {}; F.prototype = Parent.prototype; Child.prototype = new F(); Child.uber = Parent.prototype; Child.prototype.constructor = Child;}
  131. 131. var inherit = function (Child, Parent) { var F = function () {}; F.prototype = Parent.prototype; Child.prototype = new F(); Child.uber = Parent.prototype; Child.prototype.constructor = Child;}
  132. 132. classical inheritance1. Default Pattern2. Rent-a-Constructor3. Rent and Set Prototype4. Share Prototype5. Temp. Constructor
  133. 133. classical inheritance1. Default Patternklass2. Rent-a-Constructor3. Rent and Set Prototype4. Share Prototype5. Temp. Constructor
  134. 134. var Parent = klass( null, { __construct: function () {}, someMethod: function () {} });var Child = klass( Parent, { __construct: function () {}, childMethod: function () {} });
  135. 135. var Parent = klass( null, { __construct: function () {}, someMethod: function () {} });var Child = klass( Parent, { __construct: function () {}, childMethod: function () {} });
  136. 136. var Parent = klass( null, { __construct: function () {}, someMethod: function () {} });var Child = klass( Parent, { __construct: function () {}, childMethod: function () {} });
  137. 137. var Parent = klass( null, { __construct: function () {}, someMethod: function () {} });var Child = klass( Parent, { __construct: function () {}, childMethod: function () {} });
  138. 138. var Parent = klass( null, { __construct: function () {}, someMethod: function () {} });var Child = klass( Parent, { __construct: function () {}, childMethod: function () {} });
  139. 139. var Parent = klass( null, { __construct: function () {}, someMethod: function () {} });var Child = klass( Parent, { __construct: function () {}, childMethod: function () {} });
  140. 140. var Parent = klass( null, { __construct: function () {}, someMethod: function () {} });var Child = klass( Parent, { __construct: function () {}, childMethod: function () {} });
  141. 141. var Man = klass( null, { __construct: function (what) { console.log(man constructor); this.name = what; }, getName: function () { return this.name; } });
  142. 142. var Man = klass( null, { __construct: function (what) { console.log(man constructor); this.name = what; }, getName: function () { return this.name; } });
  143. 143. var Man = klass( null, { __construct: function (what) { console.log(man constructor); this.name = what; }, getName: function () { return this.name; } });
  144. 144. var Man = klass( null, { __construct: function (what) { console.log(man constructor); this.name = what; }, getName: function () { return this.name; } });
  145. 145. var Man = klass( null, { __construct: function (what) { console.log(man constructor); this.name = what; }, getName: function () { return this.name; } });
  146. 146. var Man = klass( null, { __construct: function (what) { console.log(man constructor); this.name = what; }, getName: function () { return this.name; } });
  147. 147. var Man = klass( null, { __construct: function (what) { console.log(man constructor); this.name = what; }, getName: function () { return this.name; } });
  148. 148. var first = new Man(Adam);// logs man constructorfirst.getName();// Adam
  149. 149. var first = new Man(Adam);// logs man constructorfirst.getName();// Adam
  150. 150. var first = new Man(Adam);// logs man constructorfirst.getName();// Adam
  151. 151. var first = new Man(Adam);// logs man constructorfirst.getName();// Adam
  152. 152. var SuperMan = klass( Man, { __construct: function (what) { console.log(super man constructor); }, getName: function () { var name = SuperMan.uber.getName.call(this); return I am + name; } });
  153. 153. var SuperMan = klass( Man, { __construct: function (what) { console.log(super man constructor); }, getName: function () { var name = SuperMan.uber.getName.call(this); return I am + name; } });
  154. 154. var SuperMan = klass( Man, { __construct: function (what) { console.log(super man constructor); }, getName: function () { var name = SuperMan.uber.getName.call(this); return I am + name; } });
  155. 155. var SuperMan = klass( Man, { __construct: function (what) { console.log(super man constructor); }, getName: function () { var name = SuperMan.uber.getName.call(this); return I am + name; } });
  156. 156. var SuperMan = klass( Man, { __construct: function (what) { console.log(super man constructor); }, getName: function () { var name = SuperMan.uber.getName.call(this); return I am + name; } });
  157. 157. var SuperMan = klass( Man, { __construct: function (what) { console.log(super man constructor); }, getName: function () { var name = SuperMan.uber.getName.call(this); return I am + name; } });
  158. 158. var SuperMan = klass( Man, { __construct: function (what) { console.log(super man constructor); }, getName: function () { var name = SuperMan.uber.getName.call(this); return I am + name; } });
  159. 159. var clark = new SuperMan(Clark Kent);// logs man constructor// and super man constructorclark.getName();// I am Clark Kent
  160. 160. var clark = new SuperMan(Clark Kent);// logs man constructor// and super man constructorclark.getName();// I am Clark Kent
  161. 161. var clark = new SuperMan(Clark Kent);// logs man constructor// and super man constructorclark.getName();// I am Clark Kent
  162. 162. var clark = new SuperMan(Clark Kent);// logs man constructor// and super man constructorclark.getName();// I am Clark Kent
  163. 163. var clark = new SuperMan(Clark Kent);// logs man constructor// and super man constructorclark.getName();// I am Clark Kent
  164. 164. var klass = function (Parent, props) { var Child, F, i; Child = function () { if (Child.uber && Child.uber.hasOwnProperty(__construct)) { Child.uber.__construct.apply(this, arguments); } if (Child.prototype.hasOwnProperty(__construct)) { Child.prototype.__construct.apply(this, arguments); } }; Parent = Parent || Object; F = function () {}; F.prototype = Parent.prototype; Child.prototype = new F(); Child.uber = Parent.prototype; Child.prototype.constructor = Child; for (i in props) { if (props.hasOwnProperty(i)) { Child.prototype[i] = props[i]; } } return Child;};
  165. 165. var klass = function (Parent, props) { var Child, F, i; Child = function () { if (Child.uber && Child.uber.hasOwnProperty(__construct)) { Child.uber.__construct.apply(this, arguments); } if (Child.prototype.hasOwnProperty(__construct)) { Child.prototype.__construct.apply(this, arguments); } }; Parent = Parent || Object; F = function () {}; F.prototype = Parent.prototype; Child.prototype = new F(); Child.uber = Parent.prototype; Child.prototype.constructor = Child; for (i in props) { if (props.hasOwnProperty(i)) { Child.prototype[i] = props[i]; } } return Child;};
  166. 166. var klass = function (Parent, props) { var Child, F, i; Child = function () { if (Child.uber && Child.uber.hasOwnProperty(__construct)) { Child.uber.__construct.apply(this, arguments); } if (Child.prototype.hasOwnProperty(__construct)) { Child.prototype.__construct.apply(this, arguments); } }; Parent = Parent || Object; F = function () {}; F.prototype = Parent.prototype; Child.prototype = new F(); Child.uber = Parent.prototype; Child.prototype.constructor = Child; for (i in props) { if (props.hasOwnProperty(i)) { Child.prototype[i] = props[i]; } } return Child;};
  167. 167. var klass = function (Parent, props) { var Child, F, i; Child = function () { if (Child.uber && Child.uber.hasOwnProperty(__construct)) { Child.uber.__construct.apply(this, arguments); } if (Child.prototype.hasOwnProperty(__construct)) { Child.prototype.__construct.apply(this, arguments); } }; Parent = Parent || Object; F = function () {}; F.prototype = Parent.prototype; Child.prototype = new F(); Child.uber = Parent.prototype; Child.prototype.constructor = Child; for (i in props) { if (props.hasOwnProperty(i)) { Child.prototype[i] = props[i]; } } return Child;};
  168. 168. var klass = function (Parent, props) { var Child, F, i; Child = function () { if (Child.uber && Child.uber.hasOwnProperty(__construct)) { Child.uber.__construct.apply(this, arguments); } if (Child.prototype.hasOwnProperty(__construct)) { Child.prototype.__construct.apply(this, arguments); } }; Parent = Parent || Object; F = function () {}; F.prototype = Parent.prototype; Child.prototype = new F(); Child.uber = Parent.prototype; Child.prototype.constructor = Child; for (i in props) { if (props.hasOwnProperty(i)) { Child.prototype[i] = props[i]; } } return Child;};
  169. 169. Child = function () { if (Child.uber && Child.uber.hasOwnProperty(__construct)) { Child.uber.__construct.apply(this, arguments); } if (Child.prototype.hasOwnProperty(__construct)) { Child.prototype.__construct.apply(this, arguments); }};
  170. 170. Child = function () { if (Child.uber && Child.uber.hasOwnProperty(__construct)) { Child.uber.__construct.apply(this, arguments); } if (Child.prototype.hasOwnProperty(__construct)) { Child.prototype.__construct.apply(this, arguments); }};
  171. 171. Child = function () { if (Child.uber && Child.uber.hasOwnProperty(__construct)) { Child.uber.__construct.apply(this, arguments); } if (Child.prototype.hasOwnProperty(__construct)) { Child.prototype.__construct.apply(this, arguments); }};
  172. 172. Child = function () { if (Child.uber && Child.uber.hasOwnProperty(__construct)) { Child.uber.__construct.apply(this, arguments); } if (Child.prototype.hasOwnProperty(__construct)) { Child.prototype.__construct.apply(this, arguments); }};
  173. 173. Child = function () { if (Child.uber && Child.uber.hasOwnProperty(__construct)) { Child.uber.__construct.apply(this, arguments); } if (Child.prototype.hasOwnProperty(__construct)) { Child.prototype.__construct.apply(this, arguments); }};
  174. 174. Parent = Parent || Object;F = function () {};F.prototype = Parent.prototype;Child.prototype = new F();Child.uber = Parent.prototype;Child.prototype.constructor = Child;
  175. 175. Parent = Parent || Object;F = function () {};F.prototype = Parent.prototype;Child.prototype = new F();Child.uber = Parent.prototype;Child.prototype.constructor = Child;
  176. 176. Parent = Parent || Object;F = function () {};F.prototype = Parent.prototype;Child.prototype = new F();Child.uber = Parent.prototype;Child.prototype.constructor = Child;
  177. 177. Parent = Parent || Object;F = function () {};F.prototype = Parent.prototype;Child.prototype = new F();Child.uber = Parent.prototype;Child.prototype.constructor = Child;
  178. 178. Parent = Parent || Object;F = function () {};F.prototype = Parent.prototype;Child.prototype = new F();Child.uber = Parent.prototype;Child.prototype.constructor = Child;
  179. 179. Parent = Parent || Object;F = function () {};F.prototype = Parent.prototype;Child.prototype = new F();Child.uber = Parent.prototype;Child.prototype.constructor = Child;
  180. 180. var klass = function (Parent, props) { /* ... */ for (i in props) { if (props.hasOwnProperty(i)) { Child.prototype[i] = props[i]; } } return Child;};
  181. 181. var klass = function (Parent, props) { /* ... */ for (i in props) { if (props.hasOwnProperty(i)) { Child.prototype[i] = props[i]; } } return Child;};
  182. 182. var klass = function (Parent, props) { /* ... */ for (i in props) { if (props.hasOwnProperty(i)) { Child.prototype[i] = props[i]; } } return Child;};
  183. 183. var klass = function (Parent, props) { /* ... */ for (i in props) { if (props.hasOwnProperty(i)) { Child.prototype[i] = props[i]; } } return Child;};
  184. 184. var klass = function (Parent, props) { /* ... */ for (i in props) { if (props.hasOwnProperty(i)) { Child.prototype[i] = props[i]; } } return Child;};
  185. 185. var klass = function (Parent, props) { /* ... */ for (i in props) { if (props.hasOwnProperty(i)) { Child.prototype[i] = props[i]; } } return Child;};
  186. 186. var klass = function (Parent, props) { var Child, F, i; Child = function () { if (Child.uber && Child.uber.hasOwnProperty(__construct)) { Child.uber.__construct.apply(this, arguments); } if (Child.prototype.hasOwnProperty(__construct)) { Child.prototype.__construct.apply(this, arguments); } }; Parent = Parent || Object; F = function () {}; F.prototype = Parent.prototype; Child.prototype = new F(); Child.uber = Parent.prototype; Child.prototype.constructor = Child; for (i in props) { if (props.hasOwnProperty(i)) { Child.prototype[i] = props[i]; } } return Child;};
  187. 187. X

×