Advertisement
CLooker

Untitled

Apr 13th, 2018
395
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // for loop
  2. let coll = [1, 2, 3];
  3.  
  4. for (let i = 0; i < coll.length; i++) {
  5.     coll[i] = coll[i] + 1;
  6. }
  7.  
  8. // map
  9. let coll2 = [1, 2, 3];
  10.  
  11. // notice I set what map returns to a variable
  12. // map returns a new array
  13. let newColl = coll2.map(num => num + 1);
  14.  
  15. //coll and newColl are the same thing now
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement