当前位置:首页 > Web开发 > 正文

js的call()方法

2024-03-31 Web开发

function fn(){ console.log(this) } fn.call(fn) // fn(){console.log(this)} fn.call.call(fn) // window

function fn1(){ console.log(1) } function fn2(){ console.log(2) } fn1.call(fn2) // 1 fn1.call.call(fn2) // 2  ----因为fn1.call.call()又指向window

温馨提示: 本文由Jm博客推荐,转载请保留链接: https://www.jmwww.net/file/web/42630.html