Array.prototype.at 和 String.prototype.at

版本新特性 / ES2022

// *** before: ***
var arr = [10, 20, 30];
var last = arr[arr.length - 1];
var lastChar = "hello"[("hello").length - 1];

// *** in version ES2022: ***
const arr = [10, 20, 30];
const last = arr.at(-1);
const lastChar = "hello".at(-1);