LOLWesta, a social media forum


You are not connected. Please login or register

View previous topic View next topic Go down Message [Page 1 of 1]

1
[#2] Auto-Execute Function on Thu Apr 09, 2015 8:01 am

Left


Members
Members
Tired of running wrapper function manually? Interested to run it automatically? You're in the right place.

In JavaScript, you can simply run some function manually with this :

Code:
function selfDestruct() {
 alert('Self Destruct');
}

selfDestruct();

Which is really annoying, for me.. and maybe for you. So, let's get rid of it.

Anonymous Function

So, we would need to use Anonymous Function in this time. It would run immediately because of the Anonymous Function.

Let's wrap this, why don't you:

Code:
(function() {
 alert('Self Destruct');
})();

It must self-destruct itself. Or if you want it to be named..

Code:
(function foo() {
 alert('Self Destruct example');
})();

It should work.

View user profile

View previous topic View next topic Back to top Message [Page 1 of 1]

Permissions in this forum:
You cannot reply to topics in this forum