Answers for "8.3.1. Common Array Methods // unshift Examples"

0

8.3.1. Common Array Methods // unshift Examples

//The general syntax for this method is:
arrayName.unshift(item1, item2, ...)
                  
/*This method adds one or more items to the START of an array and returns
the new length.*/

//The new items may be of any data type.

let arr = ['a', 'b', 'c'];

arr.unshift('hello', 121);

console.log(arr);

//5
//['hello', 121, 'a', 'b', 'c']
Posted by: Guest on June-14-2021

Code answers related to "8.3.1. Common Array Methods // unshift Examples"

Code answers related to "Javascript"

Browse Popular Code Answers by Language