如何使用JavaScript循环遍历数组中的所有条目?
我以为它是这样的:
forEach(instance in theArray)
Run Code Online (Sandbox Code Playgroud)
theArray我的阵列在哪里,但这似乎是不正确的.
例:
var arr = ["one","two","three"];
arr.forEach(function(part){
part = "four";
return "four";
})
alert(arr);
Run Code Online (Sandbox Code Playgroud)
数组仍然是它的原始值,有没有办法从迭代函数写入数组的元素?