Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- let cats = ["Waddles", "Snowball", "Bell", "Daisy"];
- //get an element from array
- let item = cats[2];
- console.log(`item: ${item}`); //item: "Bell"
- //change an element from array
- cats[1] = "new cat";
- console.log(cats); // ["Waddles", "new cat", "Bell", "Daisy"]
- //add value to a non-existant place in the array
- cats[5] = "bob";
- console.log(cats); // ["Waddles", "Snowball", "Bell", "Daisy", undefined, "bob"]
Add Comment
Please, Sign In to add comment