unshift()方法可向数组的开头添加一个或更多元素,并返回新的长度
arrayObject.unshift(newelement1,newelement2,newelement3,...,newelementX)
this.todos.unshift(newTodo) 等同this.todos=[newTodo,...this.todos]
this.todos=[newTodo,...this.todos] 数据放前面
this.todos=[...this.todos,newTodo] 数据放后面
本文介绍JavaScript中unshift()方法的应用,该方法用于在数组的开始处添加一个或多个元素,并返回新的长度。文章通过示例代码说明了如何使用unshift()方法以及其与数组展开语法的区别。

185

被折叠的 条评论
为什么被折叠?



