See the code segment below:
var o = {f:function(){ return this.a + this.b; }};
var p = Object.create(o);
o.a = 10;
o.b = 20;
console.log(o.f()); // output: 30
console.log(p.f()); // output: 30
The object p doesn't have property p.a and p.b then how p.f() return output 30. Is that prototype chain? Could anyone explain this? Thanks in advance.
aandbon the__proto__property ofpaandb:p.a = p.b = 5; p.f() === 10var p = jQuery.extend({},o);in jQuery.