shift unshift push pop javascript code example

Example 1: 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']

Example 2: js unshift vs push

//My Opinion is really nothing. They are the same exept one adds a element
//to the end and the other one adds a element to the front
//    Push Method
var array = [2];//your random array
array.push(3)
//    Unshift Method
array.unshift(1)