1、forEach是数组原型上的方法,Array.prototype.forEach
2、Array.prototype.forEach函数有两个参数:
参数1:是回调函数
参数2:用来改变第1个参数(函数)的this指向,选填的参数
3、参数1说明
var arr = [2,3,4];
arr.forEach(function(elem, index, array){
//回调函数的参数说明:
//第1个参数是遍历到的元素
//第2个参数是遍历到的元素的索引
//第3个参数是遍历的数组
});
4、参数2说明
1)当forEach的第2个参数传null、undefined时,第1个参数(函数)的this还是指向window
2)当forEach的第2个参数传0、空格、false时,会被自动包装成new Number(0)、new String("")、new Boolean(false)等对象