{ datagubbe }


datagubbe.se » obfuscated js

Obfuscated JavaScript

Given enough time, any language will evolve into Perl.
— Me, just now
($=(_,__=0)=>_?$(_.slice(1),+_[0]?__+(2**(_.length-1)):__):__)("10");
// --> 2

function binstr2dec(binstr, num=0) {
  if(!binstr.length) {
    return num;
  }
  if(parseInt(binstr.substring(0, 1), 10)) {
    num += Math.pow(2, binstr.length - 1);
  }
  return binstr2dec(binstr.substring(1), num);
}

(_=$=>$<=0?1:$*_($-1))(5);
// --> 120

function factorial(n) {
  if(n <= 0) {
    return 1;
  }
  return n * factorial(n - 1);
}

Reobfuscate