Answers for "Function in JavaScript that can be called only once"

4

Function in JavaScript that can be called only once

var something = (function() {
    var executed = false;
    return function() {
        if (!executed) {
            executed = true;
            // do something
        }
    };
})();

something(); // "do something" happens
something(); // nothing happens
Posted by: Guest on July-13-2020

Code answers related to "Function in JavaScript that can be called only once"

Code answers related to "Javascript"

Browse Popular Code Answers by Language