ES6 JS has nice syntax for calculating with lists:
let [car, ...cdr] = [1,2,3]
car, *cdr = [1, 2, 3, 4]
let [car, cdr @ ..] = [1,2,3];