Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adding ability to pass classical inheritance object #327

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

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