# JavaScript (ES6), <s> 83 </s> 82 bytes <!-- language-all: lang-javascript --> f=(s,a=[...new Set(s)],p)=>s.match(p)&&a.every((c,i)=>f(s,a.filter(_=>i--),[p]+c)) [Try it online!](https://tio.run/##fctBCsIwEEDRvaeQLsoMpgNN3aaX6LIUCXGikZqEJlQ8fbRbKW7/4z/0qpNZXMyND1cuxSpIQquRiDy/jgNnSDiJiKpP9NTZ3CFiXWvilZc3gBHuS3abyLo58wIX1bumQTHG6WQQiwk@hZlpDjewULWyO1eIh9@813aj7FrZdvKPbVQ@ "JavaScript (Node.js) – Try It Online") ### Commented f = ( // f is a recursive function taking: s, // s = input string a = [...new Set(s)], // a[] = list of unique characters in s p // p = current permutation, initially undefined ) => // s.match(p) && // abort if p is not found in s // NB: s.match(undefined) is truthy because it's equivalent // to looking for an empty string in s a.every((c, i) => // otherwise, for each character c at position i in a[]: f( // do a recursive call: s, // pass s unchanged a.filter(_ => i--), // remove the i-th character in a[] [p] + c // append c to p ) // end of recursive call ) // end of every()