题解 | #新数组#
1. 利用剩余参数 ...赋值给新数组 newArr
2.通过splice截取目标索引的数组项,且会直接改变被操作的数组
DOCTYPE html> html> head> meta charset=utf-8> head> body> script type="text/javascript"> let arr = ["你好", "世界", "hello", "world"] const _delete = (array, index) => { // 补全代码 let newArr = [...array] newArr.splice(index,1) return newArr } _delete(arr, 1) script> body> html>