题解 | #添加元素#
添加元素
http://www.nowcoder.com/practice/941bcfa5b87940869fda681c1597fd3a
function insert(arr, item, index) {
var newArr = [];
for(var i=0;i<arr.length;i++){
newArr.push(arr[i]) } newArr.splice(index,0,item) return newArr
}
添加元素
http://www.nowcoder.com/practice/941bcfa5b87940869fda681c1597fd3a
function insert(arr, item, index) {
var newArr = [];
for(var i=0;i<arr.length;i++){
newArr.push(arr[i]) } newArr.splice(index,0,item) return newArr
}
相关推荐