Georgi Naumov Georgi Naumov - 4 years ago 204
CoffeeScript Question

Coffeescript array destructing ignore some value

I'm using array destructing in coffeescript and it working properly:

[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?

Answer Source

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
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download