Getting the first and last element of an array in CoffeeScript
arrays, coffeescript
Solution
You can retrieve the first and last elements by using array destructuring with a splat:
[first, ..., last] = array
This splat usage is supported in CoffeeScript >= 1.7.0.
Problem
If say I have an array and I would to iterate through the array, but do something different to the first and last element. How should I do that? Taking the below code as example, how do I alert element a and e? ``` array = [a,b,c,d,e] for element in array console.log(element) ``` Thanks.