Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

check last index of array in foreach typescript

// Check if, last index of array in foreach Loop.
arr = [1, 2, 3]; 

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

PREVIOUS NEXT
Code Example
Javascript :: how to get the size of the window in javascript 
Javascript :: format date javascript 
Javascript :: how to delete a letter from a string in javascript 
Javascript :: Lazy Loading Routes vue 
Javascript :: confirm before close modal 
Javascript :: sort js 
Javascript :: how to set the development mode in webpack 
Javascript :: javascript auto scroll a page to top 
Javascript :: javascript how to select radio button 
Javascript :: hide a div in jquery 
Javascript :: angular capitalize first letter 
Javascript :: uppercase in javascript 
Javascript :: react chart js 2 
Javascript :: javascript list has item 
Javascript :: form submit event get button 
Javascript :: polling in js 
Javascript :: date format using javascript 
Javascript :: reducer in react example 
Javascript :: reset page js 
Javascript :: how to make dynamic title for screen in react native 
Javascript :: for of loop in es6 
Javascript :: active navbar in page reactjs 
Javascript :: axios delete with data 
Javascript :: random positive or negative javascript 
Javascript :: javascript DOM query selector 
Javascript :: react native filter list 
Javascript :: javascript check if object is null or empty 
Javascript :: javascript string replace all 
Javascript :: js if else 
Javascript :: jquery post form async 
ADD CONTENT
Topic
Content
Source link
Name
4+5 =