call

// Call () causes the function to execute, and the first argument changes the reference of this to the one after the argument passed into the function. The return value for the function return values If you don't pass parameters for the window Function. The prototype. MyCall =functionmyCall(context=window,... arg){let m=Symbol();
     context[m]=this;
     letres=context[m](... arg); Delete context[m]// If not deleted, the Function prototype will have a method.return res;
}
Copy the code

apply

//apply() makes the function execute. The first argument changes the reference of this inside the function to the parameter passed in. The second argument is an array and returns the value returned by the original function if no argument is passed. The default is window and []; Function.prototype.myApply=functionmyApply(context=window,... arg=[]){let m=Symbol();
      context[m]=this;
      let res=context[m](arg);
      delete context[m];
      return res;
      
  }
Copy the code

bind

 //bindThe first argument changes the reference of this inside the function to the argument passed in. The second argument is passed in as an argument to the original function, returning a new function that can be repassed, plus the second argument above. Function.prototype.myBind=functionmyBind(context=window,... arg)return(... ary)=>{return this.apply(context,arg.concat(ary));
    }
Copy the code

new

// The new function is executed, the parameter is assigned, the variable is promoted, and the heap memory is generated. This refers to the heap memory.functionmyNew(... arg){ var obj={}; var Constructor=arg.shift(); obj.__proto__=Constructor.prototype; var res=Constructor.apply(obj,arg);return typeof res==="object"? res:objreturn 
 }
Copy the code

constructor

// What is the returned data typefunction type(temp){
    let str= temp.constructor.toString();
    return str.slice(9,str.indexOf("("));
 }

Copy the code

instanceof

//instanceOf XXX instanceOf xxx2 XXX to base class prototype there is no xxx2 prototypefunction myInstance_Of(L,R){
   var r=R.prototype,
       l=L.__proto__
     while(true) {if(L===null)return false;
         if(l===r) return true; l=L.__proto_; }}Copy the code

Checks if the property is public

Object.prototype.hasPubProperty=function hasPubProperty(temp){

return temp inthis && ! this.hasOwnProperty(temp); }Copy the code