javascript学习之数组的使用二 forEach方法

array.forEach( function(value , index , object) {  });

value保存数组的值  index保存数组的索引 object保存数组本身

都可缺省

var arr=["我","爱","你"];
arr.forEach(function(value,index,object){
	console.log("index: "+index+" value:"+value);
});

猜你喜欢

转载自blog.csdn.net/Ibelievesunshine/article/details/80576312