Answers for "javascript run function once"

4

javascript run function 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 "javascript run function once"

Code answers related to "Javascript"

Browse Popular Code Answers by Language