Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

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
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #javascript #run #function
ADD COMMENT
Topic
Name
6+4 =