gpt4 book ai didi

javascript - Coffeescript 数组解构忽略某些值

转载 作者:行者123 更新时间:2023-12-03 05:07:40 25 4
gpt4 key购买 nike

我在 CoffeeScript 中使用数组解构并且它工​​作正常:

[first, second, third] = [1, 2, 3]
console.log "First:" + first, "Second:" + second, "Third:" + third

但我希望能够忽略数组元素。我想做这样的事情:

[, second, third] = [1, 2, 3]
console.log "Second:" + second, "Third:" + third

这在 EcmaScript 6 中是可能的,但如何在 Coffescript 下实现这一点?

最佳答案

我刚刚找到了如何做到这一点。这可以通过扩展运算符来完成:

[..., second, third] = [1, 2, 3]
console.log "Second:" + second, "Third:" + third

关于javascript - Coffeescript 数组解构忽略某些值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41958696/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com