//手写现实callFunction.prototype.mCall=function(context){constctx=context||窗口ctx.func=thisconstargs=Array.from(arguments).slice(1)constres=arguments.length>1?ctx.func(...args):ctx.func()删除ctx.func返回res}Function.prototype.mApply=function(context){constctx=context||windowctx.func=thisconstres=arguments[1]?ctx.func(...arguments[1]):ctx.func()删除ctx.func返回res}Function.prototype.mBind=function(context){constctx=JSON.parse(JSON.stringify(context))||窗口ctx.func=thisconstargs=Array.from(arguments).slice(1)returnfunction(){constAllargs=args.concat(Array.from(arguments))returnAllargs.length>0?ctx.func(...Allargs):ctx.func;}}constobj={getName:function(){console.log('原始。。。',this.name)}}constnowObj={name:'js'}//obj.getName.call(nowObj)obj.getName.bind(nowObj)console.log(obj)
