Answers for "shift unshift array"

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
3

shift and unshift js

let cats = ['Bob', 'Willy', 'Mini'];

cats.shift(); // ['Willy', 'Mini']

let cats = ['Bob']; 

cats.unshift('Willy'); // ['Willy', 'Bob']

cats.unshift('Puff', 'George'); // ['Puff', 'George', 'Willy', 'Bob']
Posted by: Guest on May-12-2020
0

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

Code answers related to "Javascript"

Browse Popular Code Answers by Language