
上QQ阅读APP看书,第一时间看更新
Using the unshift method
The JavaScript Array class also has a method called unshift, which inserts the values passed in the method's arguments at the start of the array (the logic behind-the-scenes has the same behavior as the insertFirstPosition method):
numbers.unshift(-2); numbers.unshift(-4, -3);
So, using the unshift method, we can add the value -2 and then -3 and -4 to the beginning of the numbers array. The output of this array will be the numbers from -4 to 13.