Skip to content

Instantly share code, notes, and snippets.

@cmilfont
Last active Oct 12, 2018
Embed
What would you like to do?
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