📜  js foreach 确定是否最后 - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:01:15.748000             🧑  作者: Mango

代码示例1
arr = [1, 2, 3]; 

arr.forEach(function(i, idx, array){
   if (idx === array.length - 1){ 
       console.log("Last callback call at index " + idx + " with value " + i ); 
   }
});