[英]Coffeescript array destructing ignore some value
I'm using array destructing in coffeescript and it working properly: 我在coffeescript中使用数组销毁,它可以正常工作:
[first, second, third] = [1, 2, 3]
console.log "First:" + first, "Second:" + second, "Third:" + third
but I want to be able to ignore array element. 但我希望能够忽略数组元素。 I want to do something like this:
我想做这样的事情:
[, second, third] = [1, 2, 3]
console.log "Second:" + second, "Third:" + third
This is possible in EcmaScript 6 but how to achieve this under Coffescript? 这在EcmaScript 6中是可能的,但是如何在Coffescript下实现呢?
I just find how to do this. 我只是找到如何做到这一点。 This can be done with expansion operator:
这可以通过扩展运算符完成:
[..., second, third] = [1, 2, 3]
console.log "Second:" + second, "Third:" + third
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.