daily pastebin goal
38%
SHARE
TWEET

Untitled

a guest Aug 18th, 2018 51 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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 );
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top