this. この便利でハマりどころの多い変数 Array.forEach / map 系 のthisArg が安定しない。 this 変数の紹介 this 変数の例 apply , call window オブジェクト コールバック イベントハンドラ Array.forEach 個人的な結論 this はできるだけ避ける 調べたキッカケは Array.forEach arr = ["A","B","C"] arr.forEach( function ( x ) { console.log ( this ) } ) このthisとして this => [“A”,“B”,“C”] を期待したわけです。 でも、this = window arr = ["A","B","C"] arr.forEach( function ( x ) { console.log ( this ) } ) //=>