Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // for loop
- let coll = [1, 2, 3];
- for (let i = 0; i < coll.length; i++) {
- coll[i] = coll[i] + 1;
- }
- // map
- let coll2 = [1, 2, 3];
- // notice I set what map returns to a variable
- // map returns a new array
- let newColl = coll2.map(num => num + 1);
- //coll and newColl are the same thing now
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement