function fn1(){console.log(1);}
function fn2(){console.log(2);}
fn1.call.call.call.call(fn2);//2
解释:
fn2.call( fn1 ) => fn1.fn2()
fn2.call === fn1.call = Function.call,
Function.call.call( fn2 ) => fn2.call() => fn2() //2
fn1.call.call.call.call(fn2)== Function.call.call.call.call(fn2)//2
=》Function.call.call.+n+.call.call(fn2)//2
=》Function.call.call( fn2 )//2 js运行模式
=》fn2.call()//2
=》fn2()// this === null 或 windows
Function.call(fn2)//chrome =>function anonymous() {}
Function(fn2) //function anonymous() {function fn2(){console.log(2);}}
时间: 2024-10-01 22:42:05