The
d3.pairs() function in D3.js is used to create pair of array elements from the given array elements. If the given array is having less than two elements then it returns the empty array.
Syntax:
d3.pairs(Array)
Parameters: This function accepts a parameter
Array whose elements are going to be paired.
Return Value: It returns the array of paired elements.
Below programs illustrate the
d3.pairs() function in D3.js.
Example 1:
Output:
[[10, 20], [20, 30], [30, 40]]
[[1, 2], [2, 3], [3, 4]]
Example 2: