Skip to content
Find file
Fetching contributors…
Cannot retrieve contributors at this time
10 lines (8 sloc) 331 Bytes

Using map is the best way to iterate through an array or object. Map uses a function to pretty much do whatever you want it to do. It will pass each value to the callback function.

//Use map to add three to each value in the array
var array = [1,2,3,4,5];

array = array.map(function(val){
  return val + 3;
});
Something went wrong with that request. Please try again.