o9s
is a microblog
home archives search feed blogroll


self-destruct

const selfdestruct = function(i) {
        console.log("This function will self destruct in " + i);

        if (i > 1) {
                i--;
        } else {
                selfdestruct = null;
        }

        selfdestruct(i);
}

selfdestruct(5);

// Output:
// This function will self destruct in 5
// This function will self destruct in 4
// This function will self destruct in 3
// This function will self destruct in 2
// This function will self destruct in 1
//
// [...]
//
// TypeError: selfdestruct is not a function
Posted on 2018-01-21   #javascript     #node  






← Next post    ยท    Previous post →