Yields the result of comparing a value with a sibling.
constdata = [ 1, 2, 4, 8, 16 ]; // Compare values with its previous sibling (-1) // Since -1 is the offset, the first A and B values will be 2 and 1, // then 4 and 2, etc. compareTo(data, -1, (a, b) =>b-a)]; // Yields: -1, -2, -4, -8
Note that one less value is yielded compared to the input array.
You can just as well go forward as well:
constdata = [ 1, 2, 4, 8, 16 ]; // Compare values with its next-next sibling (2) // With an offset of 2, the first A and B values will be 1 and 4, then // 8 and 2 etc. // then 4 and 2, etc. compareTo(data, 2, (a, b) =>b-a)]; // Yields: 3, 6, 12
Yields the result of comparing a value with a sibling.
Note that one less value is yielded compared to the input array.
You can just as well go forward as well: