خرید بک لینک

Vote count: 0

I´m learning javascript OOP and I´m having issues understanding inheritance. Could you explain me why the outcomes from this two codes differ? :

function a(){}

function b(){
    this.uno = "hello"}

b.prototype = new a();

function c(){
    this.dos = "bye"}

c.prototype= new b();

var obj = new c();

console.log(obj.uno);
console.log(obj.dos);
console.log(obj.constructor);

//hello

//bye

//[function: a]

function a(){}


function b(){
    this.uno = "hola"}


b.prototype = new a();


function c(){
    this.dos = "bye"}

c.prototype = {constructor:b}

var obj = new c();

console.log(obj.uno);
console.log(obj.dos);
console.log(obj.constructor);

//undefined

//bye

//[function: b]

I truly appreciate any guide on the subject.

asked 34 secs ago

برچسب: نویسنده: استخدام کار تاريخ: چهارشنبه 20 مرداد 1395 ساعت: 2:31

صفحه بندی