Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

functions like once

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

something(); // "do something" happens
something(); // nothing happens
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #functions
ADD COMMENT
Topic
Name
3+8 =