Skip to content

Instantly share code, notes, and snippets.

@duduindo
Created May 23, 2016 21:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save duduindo/0d5cb02ad1f50582d5450b26a6a6cd6e to your computer and use it in GitHub Desktop.
Save duduindo/0d5cb02ad1f50582d5450b26a6a6cd6e to your computer and use it in GitHub Desktop.
/**
* Multiples extends Javascript ES6
* @About: Clone method's class
**/
class SuperExtends {
constructor(ar) {
ar.forEach((item) => {
const news = new item;
const arNews = Object.getOwnPropertyNames(news.constructor.prototype);
arNews.shift();
arNews.forEach((val) => {
this.constructor.prototype[val] = news.constructor.prototype[val];
});
});
}
}
/**
* Using/Example
**/
class Head {
snout() {}
mouth() {}
}
class Body {
core() {}
stomach() {}
}
class Dog extends SuperExtends {
constructor() {
super([Head, Body]);
console.dir(this); //Console in browser: Dog > __proto__
}
}
new Dog();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment