Could anyone help me with this troubleshooting?
var something = (function() {
var executed = false;
return function() {
if (!executed) {
executed = true;
alert("Hi");
}
};
})(); //Removing the following calls the function does not execute with parenthesis
something(); //Happens
something(); //Nothing happens
My Approach:
var only = (function once() {
alert("Kaixo");
only = false;
})(); //That parenthesis calls the function
only(); //Calls the function
only(); //Nothing happens
If my example is run before the original, breaks. Continuing of this topic: Function in javascript that can be called only once