SOURCE

var res=[];
function dfs(p){
    if(res.length==p.length){
        console.log(res.join(' '));
        return;
    }
    for(let i=0;i<p.length;i++){
        let temp=p[i];
        p[i]=null;
        if(temp){
            res.push(temp);
            dfs(p);
            res.pop();
            p[i]=temp;
        }
    }
}

let pp=['a','b','c'];
dfs(pp)
console 命令行工具 X clear

                    
>
console