李振良-KubernetesK8s CKA 認(rèn)證實(shí)戰(zhàn)班
2022-11-13 21:06 作者:bili_1559000721 | 我要投稿
示例三
let arr = []for( let i = 0; i < 3; i++ ){
? ?arr[ i ] = function(){
? ? ? ?console.log( this )
? ?}}let fn = arr[ 0 ]arr[ 0 ]fn()
上述中的 this
會(huì)打印出什么呢?
arr[ 0 ] ==> arr 對(duì)象{ 0: fn, 1: fn, 2: fn } ==> arr.0 ==> arr.0.call( this ) ==> this === arrfn() ==> fn.call( undefined ) ==> this === undefined == 瀏覽器轉(zhuǎn)化 ==> window
標(biāo)簽: