Files
  • index.js
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
with(insanity()) {
    log("You want to learn JavaScript? That's great! Let's do it completely wrong with a 100% wrong tutorial.");

    log("\nLet's begin with some simple barewords:");
    log(greetings);
    log([good, morning, world].join(" "));

    log("\nALL CAPS means it's a concat function, right?");
    log(HELLO(world));
    log(THIS(IS(REALLY((great)))).toLowerCase());

    log("\nWe can use simple prefixes, like 'flip' to modify our barewords:");
    log(backwards);
    log(flipbackwards);
    log(flipbackwardspilf);

    log("\nJust because we have barewords doesn't mean we can't have variables, too");
    log("rose is", rose);
    rose = violet;
    log("rose is", rose);
    rose = violet = tulip;
    log("rose is", rose, "is", violet);

    log("\nAnd a 'sizeof' prefix is really nice for quick length-checking:");
    log(foobar, "has length", sizeoffoobar);
    log(rose, "has length", sizeofrose);
    log(baz, "has length", baz[length]);
    log(antidisestablishmentarianism, "is longer than", foobar, "by",
        sizeofantidisestablishmentarianism - sizeoffoobar, "characters!");

    log("\nIn conclusion,");
    log(THIS(IS(spart + a[repeat](20))));
    log(AND(flipRETTU(nonsense + "!")));

    log(SEE(YOU(NEXT(time[toUpperCase]()))));

    log("Remember kids, this is absolutely terrible. Please don't actually do this.")
}

/*---------------------*/

function insanity() {
    return new Proxy({log:console.log},{
        has:a=>!0,
        get:function getter(o,s){
            if(typeof s !== "string") return eval(s);
            if(s in o) return o[s];
            if(s.toUpperCase()==s) return x=>s+" "+x;
            if(s.match(/^flip/i)) return getter(o,[...s.substr(4)].reverse().join``);
            if(s.match(/^sizeof/i)) return getter(o,s.substr(3)).length;
            return s;
        }
    })
}
node v9.7.1 linux/amd64