We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Array.prototype._splice = function(start, count, ...args){ const arr = this // 原数组 const res = [] // 结果 const addArr = args // 添加的数据 const changeIndexs = [] // 需要往后移动的下标 if(!count) count = arr.length - start // count不存在时取 arr.length - start // 移动下标到最后 const move = (index) => { const tmp = arr[index] for(let i = index;i<arr.length - 1; i++){ arr[i] = arr[i+1] } arr[arr.length - 1] = tmp } for(let i = 0; i< count; i++){ const startIndex = start + i res.push(arr[startIndex]) // 记录删除的结果 changeIndexs.push(startIndex) // 记录需要移动的下标 } for(item of changeIndexs){ move(item) } arr.length = arr.length - res.length return res }
The text was updated successfully, but these errors were encountered:
No branches or pull requests
The text was updated successfully, but these errors were encountered: