12345678
> const a = ['a', 'b', 'c', 'd']undefined> a.slice(-1)["d"]> a.slice(0, -1)["a", "b", "c"]> a.slice(0, a.length)["a", "b", "c", "d"]
可使用负数索引,表示由数组的最末项开始提取。