Answers for "shift unshift"

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
10

unshift method in javascript

var name = [ "john" ];
name.unshift( "charlie" );
name.unshift( "joseph", "Jane" );
console.log(name);

//Output will be
[" joseph "," Jane ", " charlie ", " john "]
Posted by: Guest on August-02-2020
0

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)
Posted by: Guest on July-15-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