functions like once

Solutions on MaxInterview for functions like once by the best coders in the world

showing results for - "functions like once"
Chantal
01 May 2016
1var something = (function() {
2    var executed = false;
3    return function() {
4        if (!executed) {
5            executed = true;
6            // do something
7        }
8    };
9})();
10
11something(); // "do something" happens
12something(); // nothing happens
13
similar questions
queries leading to this page
functions like once