Array (array) object-> unshift () method

1. Definition and usage

  The unshift () method adds one or more elements to the beginning of the array and returns the new length.

  grammar:

    array.unshift(item1,item2, ..., itemX)

    Parameters: item1 , item2 , ...,  itemX add one or more elements to the beginning of the array.

  Note:  This method will change the number of arrays

  Examples:

var arr = [1,2,3,4,5];
arr.unshift(6,7,8);
console.log(arr);

  Output:

 

Guess you like

Origin www.cnblogs.com/abner-pan/p/12683110.html