Thursday, September 25, 2025
HomeLanguagesJavascriptD3.js permute() method

D3.js permute() method

With the help of d3.permute() method, we can get the array of the values from the source object using specified keys and returns a copy of a permuted array.

Syntax:

d3.permute(source, keys)

Return value: It returns the array of values.

Note: To execute the below examples you have to install the d3 library by using the command prompt for the following command.

npm install d3

Example 1: In this example, we can see that by using d3.permute() method, we are able to get the single array after permutation having values specified in the source array and using keys for the permutation.

Javascript




// Defining d3 contrib variable
const d3 = require('d3');
 
const gfg = d3.permute([1, 2, 3, 4], [3, 2, 1, 0]);
 
console.log(gfg);


Output:

[ 4, 3, 2, 1 ]

Example 2:

Javascript




// Defining d3 contrib variable
const d3 = require('d3');
 
let gfg = d3.permute
    (["Geeks", "Geeks", "for"], [0, 2, 1]);
 
console.log(gfg);


Output:

[ 'Geeks', 'for', 'Geeks' ]
Whether you’re preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, neveropen Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we’ve already empowered, and we’re here to do the same for you. Don’t miss out – check it out now!
RELATED ARTICLES

Most Popular

Dominic
32319 POSTS0 COMMENTS
Milvus
84 POSTS0 COMMENTS
Nango Kala
6681 POSTS0 COMMENTS
Nicole Veronica
11854 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11910 POSTS0 COMMENTS
Shaida Kate Naidoo
6794 POSTS0 COMMENTS
Ted Musemwa
7070 POSTS0 COMMENTS
Thapelo Manthata
6753 POSTS0 COMMENTS
Umr Jansen
6761 POSTS0 COMMENTS