var arr = [{name:'b',id:12},{name:'c',id:21},{name:'a',id:2}]; var list = arr.slice(0,2); console.log(list) //[ { name: 'b', id: 12 }, { name: 'c', id: 21 } ]
截取数组元素slice
最新推荐文章于 2023-08-16 23:03:28 发布
var arr = [{name:'b',id:12},{name:'c',id:21},{name:'a',id:2}]; var list = arr.slice(0,2); console.log(list) //[ { name: 'b', id: 12 }, { name: 'c', id: 21 } ]