Returns a function which yields difference compared to last value.
If no initial value is provided, the first difference will be returned as 0.
Difference can be returned in various formats:
Use differenceFromFixed to compare against a fixed value instead of the last value.
let d = differenceFromLast(`absolute`);d(10); // 0d(11); // 1d(10); // 1 Copy
let d = differenceFromLast(`absolute`);d(10); // 0d(11); // 1d(10); // 1
let d = differenceFromLast(`numerical`);d(10); // 0d(11); // 1d(10); // -1 Copy
let d = differenceFromLast(`numerical`);d(10); // 0d(11); // 1d(10); // -1
let d = differenceFromLast(`relative`);d(10); // 0d(11); // 0.1d(10); // 0.1 Copy
let d = differenceFromLast(`relative`);d(10); // 0d(11); // 0.1d(10); // 0.1
let d = differenceFromLast(`relativeSigned`);d(10); // 0d(11); // 0.1d(10); // -0.1 Copy
let d = differenceFromLast(`relativeSigned`);d(10); // 0d(11); // 0.1d(10); // -0.1
An initial value can be provided, eg:
let d = differenceFromLast(`absolute`, 10);d(11); // 1 Copy
let d = differenceFromLast(`absolute`, 10);d(11); // 1
Kind of output value
Optional initial value
Returns a function which yields difference compared to last value.
If no initial value is provided, the first difference will be returned as 0.
Difference can be returned in various formats:
Use differenceFromFixed to compare against a fixed value instead of the last value.
An initial value can be provided, eg: