at()方法接收一个整数值并返回该索引的项目,允许正数和负数,
正数是从头开始索引,负数是从尾开始索引
找不到就返回undefined
const array1 = [5, 12, 8, 130, 44];
console.log(array1.at(2)); //8
console.log(array1.at(-2)); //130
console.log(array1.at(7)); //undefined
at()方法接收一个整数值并返回该索引的项目,允许正数和负数,
正数是从头开始索引,负数是从尾开始索引
找不到就返回undefined
const array1 = [5, 12, 8, 130, 44];
console.log(array1.at(2)); //8
console.log(array1.at(-2)); //130
console.log(array1.at(7)); //undefined