Skip to content

compute diff

kgryte edited this page May 12, 2015 · 1 revision

Calculates the differences between adjacent elements in an array.

var arr = [ 2, 1, 3, 4 ];

var diff = compute.diff( arr );
// returns [ 1, -2, -1 ]

Note: the length of the returned array is one less than the length of the original array.

Clone this wiki locally