数组prototype 一些冷门方法

arr
(6) ["a", "b", "c", "d", "e", "f"]
arr[-1]
undefined
arr[1]
"b"
arr.at(1)
"b"
arr.at(-1)
"f"
const array1 = ['a', 'b', 'c', 'd', 'e'];

// copy to index 0 the element at index 3
console.log(array1.copyWithin(0, 3, 4));
// expected output: Array ["d", "b", "c", "d", "e"]

// copy to index 1 all elements from index 3 to the end
console.log(array1.copyWithin(1, 3));
// expected output: Array ["d", "d", "e", "d", "e"]
const array1 = [5, 12, 8, 130, 44];

const isLargeNumber = (element) => element > 13;

console.log(array1.findIndex(isLargeNumber));
// expected output: 3

上一篇:向pom文件中拷贝依赖 expected START_TAG or END_TAG not TEXT (position: TEXT seen ...


下一篇:eslint 错误提示