let obj={
name:'金毛'
}
function test(){
console.log(123,this)
}
test.call(obj,'123')
//手写
Function.prototype.myCall=function(thisObj,arr){
let Fn = this
let s =Symbol('func')
let s2 =Symbol('func')
let del =Object.getOwnPropertySymbols(thisObj)
delete thisObj[del[0]]
thisObj[s]=Fn
thisObj[s](arr)
}//手写call
let obj={
name:'金毛'
}
function test(){
console.log(123,this)
}
test.call(obj,'123')
//手写
Function.prototype.myCall=function(thisObj,arr){
let Fn = this
return function (){
let s =Symbol('func')
let s2 =Symbol('func')
let del =Object.getOwnPropertySymbols(thisObj)
delete thisObj[del[0]]
thisObj[s]=Fn
thisObj[s](arr)
}
}//bind