I want to convert following code (ignore console.log) to jsfuck convention where only characters []()!+
are allowed (but here for clarity also numbers and strings with a-Z and 0-9 chars are allowed (wrapped by double quotes) - because conversion such strings/numbers to []()!+
is easy)
console.log(
[1,2,3,4,5].map(x=>x**2)
)
After partial conversion I have
console.log(
[1,2,3,4,5]["map"]([]["fill"]["constructor"]("return(2)"))
)
The problem is that I'm unable to pass argument x
into map function.
Question: How to convert function x=>x**2
to jsf and pass it as map
argument?
(I don't want to use 'eval' like solutions where we put map
inside string which will be executed as code e.g. []["fill"]["constructor"]('return [1,2,3,4,5].map(x=>x**2)')()
- this is forbidden)
The function constructor takes more than one argument:
[]["fill"]["constructor"]('x', 'return x ** 2;')