#unshift array

3 messages · Page 1 of 1 (latest)

chrome mica
#

//the code
const friends = ['Michael', 'Steven', 'Peter'];

friends.push('Jay');
console.log(friends);

friends.unshift('John');
console.log(friends);

tired wind
#

this is just a quirk with the console and doesn't have to do with unshift, but because you're modifying the array

#

viewing the contents shows you the updated object, but at the time console.log is executed the array does have the contents you expect