Answers for "how to use unshift() and shift()"

1

how to use unshift() and shift()

//to add the first item to a array 

let top_salespeople = ['Lucy', 'Graham', 'Carol', 'Ann'];
top_salespeople.unshift('Hannah');

console.log(top_salespeople);
Posted by: Guest on August-24-2021
1

how to use unshift() and shift()

//to remove the first item from array 

let top_salespeople = ['Mark', 'Lucy', 'Graham', 'Carol', 'Ann'];
top_salespeople.shift();

console.log(top_salespeople);
Posted by: Guest on August-24-2021

Browse Popular Code Answers by Language