Guest User

Untitled

a guest
Jan 19th, 2018
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.40 KB | None | 0 0
  1. let cats = ["Waddles", "Snowball", "Bell", "Daisy"];
  2.  
  3. //get an element from array
  4. let item = cats[2];
  5. console.log(`item: ${item}`); //item: "Bell"
  6.  
  7. //change an element from array
  8. cats[1] = "new cat";
  9. console.log(cats); // ["Waddles", "new cat", "Bell", "Daisy"]
  10.  
  11. //add value to a non-existant place in the array
  12. cats[5] = "bob";
  13. console.log(cats); // ["Waddles", "Snowball", "Bell", "Daisy", undefined, "bob"]
Add Comment
Please, Sign In to add comment