Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function extensibleObject() {
- let objProto = {};
- let instanceObj = Object.create(objProto);
- instanceObj.extend = function (templates) {
- Object.entries(templates).forEach(([key, value]) => {
- if (typeof value === 'function') {
- objProto[key] = value;
- } else {
- instanceObj[key] = value;
- }
- });
- }
- return instanceObj;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement