Skip to content

Instantly share code, notes, and snippets.

@cmilfont
Last active October 12, 2018 11:45
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cmilfont/1469790766cff5849ed8515349ee2a77 to your computer and use it in GitHub Desktop.
Save cmilfont/1469790766cff5849ed8515349ee2a77 to your computer and use it in GitHub Desktop.
return true to win

[https://alf.nu/ReturnTrue]

function reflexive(x) {
    return x != x;
}
reflexive(NaN)

function transitive(x,y,z) {
    return x && x == y && y == z && x != z;
}
transitive([], 0 , [])

function counter(f) {
    var a = f(), b = f();
    return a() == 1 && a() == 2 && a() == 3
        && b() == 1 && b() == 2;
}
counter((c = 1 ) => (() => c++))

function peano(x) {
    return (x++ !== x) && (x++ === x);
}
peano(2**53-1)

function proto1(x) {
    return x && !("__proto__" in x);
}
proto1(Object.create(null))

function symmetric(x,y) {
    return x == y && y != x;
}
symmetric(i=0,{valueOf:_=>i++})

function ouroborobj(x) {
    return x in x;
}
ouroborobj([0])

function truth(x) {
    return x.valueOf() && !x;
}
truth((() => { Number.prototype.valueOf =() => true; return Number(0); })())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment