Spacebar
Jump to navigation
Jump to search
Spacebar is an esoteric variant of JavaScript. The Spacebar interpreter first takes your code and adds spaces in random locations. Then it interprets your code as JavaScript. More specifically, by random we mean that for each character in your code there is a 50% chance that a space will be inserted before it. This action is determined independently for each character.
Examples
Hello, World!
This program prints out the words Hello World!:
F = ![] T = !![] U = [][[]] d = (U+[])[2] e = (T+[])[3] f = (F+[])[0] i = (U+[])[5] l = (F+[])[2] n = (U+[])[1] r = (T+[])[1] s = (F+[])[3] t = (T+[])[0] u = (U+[])[0] L = f+i+n+d c = ([][L]+[])[3] j = ([]+[][e+n+t+r+i+e+s]())[3] o = ([T]+[][L])[1+[0]] C = c+o+n+s+t+r+u+c+t+o+r X = (U+[])[1]+(F+[])[1]+([]+(+[])[C])[1+[1]]+(T+[])[3] Y = (T+[])[0]+([T]+[][L])[1+[0]]+([]+[])[C][X] p = (+(2+[1]+[1]))[Y](3+[1])[1] S = s+p+l+i+t J = j+o+i+n ; [][L][C]( "console.log('Hello"[S](" "[0])[J]([]) + " "[0] + "World!')"[S](" "[0])[J]([]) )()
This Hello World! example borrows significantly from work done to make a JSFuck encoder. As in JSFuck, find and constructor are used to simulate eval. split and join are used to remove any spaces from a string. Recall that the interpreter may or may not insert random spaces in the string.
Interpreter
Written in JavaScript.
function spacebar(program) { let result = ""; for(const char of program) { if(Math.random() < 0.5) result += " "; result += char; } eval(result); }
See also
- Spaced, a variant where all characters have space inserted between them