Guest User

Untitled

a guest
Aug 18th, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.48 KB | None | 0 0
  1. /***************************************
  2. Array.from()
  3. -create a new shallow copy array
  4. ***************************************/
  5.  
  6. let names = ['Bart','Maggie','Homer','Marge','Lisa'];
  7. let stuff = [123, 'Apu',
  8. {Smithers: 'Mr. Burns'},
  9. ['Futurama', 'Disenchantment']];
  10.  
  11. let nm2 = Array.from(names);
  12. let st2 = Array.from(stuff);
  13.  
  14. nm2[4] = 'Flanders';
  15.  
  16. st2[2].Smithers = 'Not Mr. Burns';
  17.  
  18. console.log( stuff);
  19. console.log( st2);
  20.  
  21. console.log( names );
  22. console.log( nm2 );
Add Comment
Please, Sign In to add comment