I was watching a session by Kyle Simpson about the object inheritance in javascript and he introduced this term that he called OLOO. Where b1 delegates to Bar delegates to Foo as in the example below:
Code
var Foo={
init: function(who){
this.me=who;
},
identify:function(){
return "I am "+ this.me;
}
};
var Bar=Object.create(Foo);
Bar.speak=function(){
alert("Hello, "+this.identify() +".");
};
var b1=Object.create(Bar);
b1.init("b1");
b1.speak();
Equivalent complicated code -->
Code
var Foo={
![]() | ||
A screenshot from Kyle Simpson slides |
init: function(who){
this.me=who;
},
identify:function(){
return "I am "+ this.me;
}
};
var Bar=Object.create(Foo);
Bar.speak=function(){
alert("Hello, "+this.identify() +".");
};
var b1=Object.create(Bar);
b1.init("b1");
b1.speak();
Equivalent complicated code -->
No comments:
Post a Comment