Skip to content

Conversation

@teknosains
Copy link

@teknosains teknosains commented Sep 13, 2018

adding ability to pass classical inheritance object

co(function* () {
  function Human(name, age) {
    this.name = name;
    this.age = age;
  }

  Human.prototype.getName = function() {
    return this.name;
  };

  Human.prototype.getAge = function() {
    return this.age;
  }

  let Asian = function(name, age) {
    Human.call(this, name, age);
    this.country = 'Brunei';
  }

  Asian.prototype = Object.create(Human.prototype);

  let agus = new Asian('Agus', 29);

  let res = yield agus;

  console.log(res); // { name: 'Agus', age: 29, country: 'Brunei' }
  console.log(res.getName()); // Agus
  console.log(res.country); // brunei
})
.catch(function(e) {
  console.log(e);
});

adding ability to pass classical inhertiance object

```
co(function* () {
  function Human(name, age) {
    this.name = name;
    this.age = age;
  }

  Human.prototype.getName = function() {
    return this.name;
  };

  Human.prototype.getAge = function() {
    return this.age;
  }

  let Asian = function(name, age) {
    Human.call(this, name, age);
    this.country = 'Brunei';
  }

  Asian.prototype = Object.create(Human.prototype);

  let agus = new Asian('Agus', 29);

  let res = yield agus;
  console.log(typeof res);
  console.log(res); // { name: 'Agus', age: 29, country: 'Brunei' }
  console.log(res.getName()); // Agus
  console.log(res.country); // brunei
})
.catch(function(e) {
  console.log(e);
});

```
@teknosains teknosains changed the title adding ability to pass classical inhertiance object adding ability to pass classical inhertance object Sep 13, 2018
@teknosains teknosains changed the title adding ability to pass classical inhertance object adding ability to pass classical inheritance object Sep 13, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant