slice() 方法可从已有的数组中返回选定的元素。
语法 arrayObject.slice(start,end) 实现 Array.prototype.slice?=?function(start,?end){ start?=?start?===?undefined???0?:?start; end?=?end?===?undefined???this.length?:?end; var?res?=?[]; for(var?i?=?start;?i?<?end;?i++){ res.push(this[i]); } return?res;} 测试 var arr = [1,2,4,5,65,6,56,46,456,45,645,645,6];console.log(arr);var res = arr.slice(2, 8);console.log(res);?
23415926