Advertisement
EntropyStarRover

04. Extensible Object

Nov 5th, 2019
197
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function result(){
  2. let myObj={__proto__: {}}
  3. myObj.extend=function(template){
  4. let tmplArr=Object.entries(template);
  5.  
  6. tmplArr.forEach(key=>{
  7.     let k=key[0];
  8.     let v=key[1];
  9.  
  10.    if (typeof (v)=="function"){
  11.    
  12.        myObj.__proto__[k]=v;
  13.      
  14.    } else {
  15.        myObj[k]=v;
  16.    }
  17.  
  18. })
  19.  
  20. }
  21. return myObj;
  22. }
Advertisement
RAW Paste Data Copied
Advertisement