showing results for - "8 3 1 common array methods 2f 2f unshift examples"
Mía
31 Jul 2016
1//The general syntax for this method is:
2arrayName.unshift(item1, item2, ...)
3                  
4/*This method adds one or more items to the START of an array and returns
5the new length.*/
6
7//The new items may be of any data type.
8
9let arr = ['a', 'b', 'c'];
10
11arr.unshift('hello', 121);
12
13console.log(arr);
14
15//5
16//['hello', 121, 'a', 'b', 'c']