push information to an array but at index 0

This question already has an answer here:

  • How can I add new array elements at the beginning of an array in JavaScript? 6 answers

  • Use unshift() :

    array1.unshift({'newEntry' : 'newEntry-value'});
    

    JS Fiddle demo.

    References:

  • unshift() .

  • yourArray.unshift(newValue)将一个项目推到数组的前面。

    链接地址: http://www.djcxy.com/p/19350.html

    上一篇: 将项目添加到列表的开头

    下一篇: 将信息推送到数组,但在索引0处