Answers for "functions like once"

0

functions like 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 March-17-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language