Skip to content

Instantly share code, notes, and snippets.

@mearns
Created November 8, 2018 16:39
Show Gist options
  • Save mearns/7c45fc4dd4dac62702804cceb2a06fc1 to your computer and use it in GitHub Desktop.
Save mearns/7c45fc4dd4dac62702804cceb2a06fc1 to your computer and use it in GitHub Desktop.
// Based on : https://github.com/aemkei/jsfuck/blob/master/jsfuck.js
_zero = +[] // 0
_false = !!+[] // false
_falseStr = !!+[]+[] // 'false'
_f = (!!+[]+[])[+[]] // 'f' <= 'false'[0]
_undefined = [][[]] // undefined <= [][''] (the property named '' on the array object, which is undefined (property accessors are always cast to strings))
_undefinedStr = [][[]]+[] // 'undefined'
_true = !+[] // true <= !0
_one = +!+[] // 1 <= +true (true, cast to a number)
_two = +!+[]+(+!+[]) // 2 <= 1+1
_three = +!+[]+(+!+[])+(+!+[])
_four = +!+[]+(+!+[])+(+!+[])+(+!+[])
_five = +!+[]+(+!+[])+(+!+[])+(+!+[])+(!+[])
_i = ([][[]]+[])[+!+[]+(+!+[])+(+!+[])+(+!+[])+(!+[])] // 'i' <= 'undefined'[5]
_l = (!!+[]+[])[+!+[]+(+!+[])] // 'l' <= 'false'[2]
_fillStr = (!!+[]+[])[+[]]+([][[]]+[])[+!+[]+(+!+[])+(+!+[])+(+!+[])+(!+[])]+(!!+[]+[])[+!+[]+(+!+[])]+(!!+[]+[])[+!+[]+(+!+[])] // 'fill' <= 'f'+'i'+'l'+'l'
_fillFunction = [][(!!+[]+[])[+[]]+([][[]]+[])[+!+[]+(+!+[])+(+!+[])+(+!+[])+(!+[])]+(!!+[]+[])[+!+[]+(+!+[])]+(!!+[]+[])[+!+[]+(+!+[])]] // <= []['fill']
_fillFunctionStr = [][(!!+[]+[])[+[]]+([][[]]+[])[+!+[]+(+!+[])+(+!+[])+(+!+[])+(!+[])]+(!!+[]+[])[+!+[]+(+!+[])]+(!!+[]+[])[+!+[]+(+!+[])]]+[] // 'function fill() { [native code] }'
_c = ([][(!!+[]+[])[+[]]+([][[]]+[])[+!+[]+(+!+[])+(+!+[])+(+!+[])+(!+[])]+(!!+[]+[])[+!+[]+(+!+[])]+(!!+[]+[])[+!+[]+(+!+[])]]+[])[+!+[]+(+!+[])+(+!+[])] // 'c' <= 'function fill...'[3]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment