Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

javaScript forEach this argument

const colors = ['blue', 'green', 'white'];
function iterate(item, index, array) {
  console.log(item);
  if (index === array.length - 1) {
    console.log('The last iteration!');
  }
}
colors.forEach(iterate);
// logs "blue"
// logs "green"
// logs "white"
// logs "The last iteration!"
Source by dmitripavlutin.com #
 
PREVIOUS NEXT
Tagged: #javaScript #forEach #argument
ADD COMMENT
Topic
Name
8+6 =