Monday, June 15, 2026
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

2 COMMENTS

Most Popular

Dominic
32516 POSTS0 COMMENTS
Milvus
131 POSTS0 COMMENTS
Nango Kala
6897 POSTS0 COMMENTS
Nicole Veronica
12013 POSTS0 COMMENTS
Nokonwaba Nkukhwana
12109 POSTS0 COMMENTS
Shaida Kate Naidoo
7019 POSTS0 COMMENTS
Ted Musemwa
7262 POSTS0 COMMENTS
Thapelo Manthata
6976 POSTS0 COMMENTS
Umr Jansen
6964 POSTS0 COMMENTS