str.split('.').pop()
const {password, ...rest} = user;
console.log(password);
console.log(rest);
return rest;
function permut8(arr, prepend) {
var i, version, el, result = [];
prepend = prepend || [];
if(arr.length === 1) return [arr];
for( i=0; i<arr.length; i++) {
if( arr.length === 2) {
result.push( prepend.concat( [arr[i], arr[(i+1)%2]] ));
} else {
version = arr.slice();
el = version.splice(i,1);
result = result.concat( permut8( version, prepend.concat(el)));
}
}
return result;
}
var test = permut8( 'abcd'.split('') );
test.map( e=>e.join(' ')).join("\n")
/*
a b c d
a b d c
a c b d
a c d b
a d b c
a d c b
b a c d
b a d c
b c a d
b c d a
b d a c
b d c a
c a b d
c a d b
c b a d
c b d a
c d a b
c d b a
d a b c
d a c b
d b a c
d b c a
d c a b
d c b a
*/
["a", "a"]
получим два одинаковых [["a", "a"], ["a", "a"]]
function nextLexInPlace(arr){
var i, a = -1, b = -1;
for( i = 0; i < arr.length-1; i++) if(arr[i] < arr[1+i]) a = i;
if( !~a) return; // no more permutations
for( i = a + 1; i < arr.length; i++) if(arr[a] < arr[i]) b = i;
swap(arr, a, b);
a++;
b = arr.length - 1;
while( a < b) swap(arr, a++, b--);
return true;
}
function swap( arr, a, b) {
var xx = arr[a];
arr[a] = arr[b];
arr[b] = xx;
}
function allMutations( source) {
var result = [], arr = source.slice();
result.push( arr.sort().slice());
while( nextLexInPlace(arr)) result.push(arr.slice());
return result;
}
var test = ['a','c','c']; JSON.stringify( allMutations(test))
// [["a","c","c"],["c","a","c"],["c","c","a"]]
function* permutator(arr) {
var i, a, b;
function swap( arr, a, b) {
var xx = arr[a];
arr[a] = arr[b];
arr[b] = xx;
}
yield arr.slice();
while(true) {
a = -1, b = -1;
for( i = 0; i < arr.length-1; i++) if(arr[i] < arr[1+i]) a = i;
if( !~a) return;
for( i = a + 1; i < arr.length; i++) if(arr[a] < arr[i]) b = i;
swap(arr, a++, b);
b = arr.length - 1;
while( a < b) swap(arr, a++, b--);
yield arr.slice();
}
}
function allMutations( source) {
var all = [], result, G = permutator(source.slice().sort());
while(true) {
result = G.next();
if(result.done) break;
all.push( result.value);
}
return all;
}
var test = ['a','c','c']; JSON.stringify( allMutations(test))
// [["a","c","c"],["c","a","c"],["c","c","a"]]