Advertisement
bebo231312312321

Untitled

Jun 8th, 2023
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function extensibleObject() {
  2.     let objProto = {};
  3.     let instanceObj = Object.create(objProto);
  4.  
  5.     instanceObj.extend = function (templates) {
  6.       Object.entries(templates).forEach(([key, value]) => {
  7.         if (typeof value === 'function') {
  8.           objProto[key] = value;
  9.         } else {
  10.           instanceObj[key] = value;
  11.         }
  12.       });
  13.     }
  14.  
  15.     return instanceObj;
  16.   }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement