javascript 에서 immutable하게 head, tail 을 만들 수 있는 방법.
var array = [1, 2, 3, 4, 5];
var head = array[0];
var tail = array.slice(1);
// ES6
const array = [1, 2, 3, 4, 5];
const head = ([head]) => head;
const tail = ([, ...tail]) => tail;
참고:
https://stackoverflow.com/questions/35361225/javascript-head-and-tail-on-array-without-mutation#49105244