最佳答案
当我只对索引0以外的数组值感兴趣时,在数组解构时,我可以避免声明一个无用的变量吗?
在下面的内容中,我想避免声明 a
,我只对索引1及以后的内容感兴趣。
// How can I avoid declaring "a"?
const [a, b, ...rest] = [1, 2, 3, 4, 5];
console.log(a, b, rest);