我在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下实现这一目标?
答案 0 :(得分:1)
我只是想知道如何做到这一点。这可以通过扩展运算符来完成:
[..., second, third] = [1, 2, 3]
console.log "Second:" + second, "Third:" + third