If you prefer functional programming, here is a solution using map :
function diff(A) { return A.slice(1).map(function(n, i) { return n - A[i]; }); }
A little explanation: slice(1) gets everything except the first element. map returns a new value for each of them, and the return value is the difference between the element and the corresponding element in (array un- slice d), therefore A[i] is the element before [i] in the slice.
Here is jsfiddle: https://jsfiddle.net/ewbmrjyr/2/
Roy j source share