JavaScript implementation of array full array output code

From , 2 Years ago, written in JavaScript, viewed 235 times.
URL https://pastebin.vip/view/b4523228
  1. var permArr = [],
  2. usedChars = [];
  3. //code from http://www.sharejs.com
  4. function permute(input) {
  5.     var i, ch;
  6.     for (i = 0; i < input.length; i++) {
  7.         ch = input.splice(i, 1)[0];
  8.         usedChars.push(ch);
  9.         if (input.length == 0) {
  10.             permArr.push(usedChars.slice());
  11.         }
  12.         permute(input);
  13.         input.splice(i, 0, ch);
  14.         usedChars.pop();
  15.     }
  16.     return permArr
  17. };
  18.  
  19.  
  20. console.log(permute([5, 3, 7, 1]));
  21. //javascript/8710

Reply to "JavaScript implementation of array full array output code"

Here you can reply to the paste above

captcha

https://burned.cc - Burn After Reading Website