forEach函数调用的调用上下文(this) [英] The invocation context (this) of the forEach function call
本文介绍了forEach函数调用的调用上下文(this)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想知道'this'值(或调用上下文)是什么forEach回调函数。这段代码似乎不起作用:
I was wondering what the 'this' value (or invocation context) is of the forEach callback function. This code doesn't seem to work:
var jow = [5, 10, 45, 67];
jow.forEach(function(v, i, a){
this[i] = v + 1;
});
alert(jow);
Thx向我解释。
Thx for explaining it to me.
推荐答案
我完成了forEach方法的构建,并希望与大家分享这个图,希望它能帮助别人试图理解它的内部运作。
I finished construction of the forEach method and wanted to share this diagram with everyone, hope it helps someone else trying to understand its inner workings.
这篇关于forEach函数调用的调用上下文(this)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文