Advertisement
kstoyanov

04. Extensible Object -v2-

Oct 13th, 2020
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. myObj = () => ({
  2.     __proto__: {},
  3.     extend: function (template) {
  4.         Object.entries(template).forEach(([key, value]) => {
  5.             if (typeof value === "function") {
  6.                 this.__proto__[key] = value;
  7.             } else {
  8.                 this[key] = value;
  9.             }
  10.         });
  11.     }
  12.  
  13. })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement