Self executing function in JavaScript

Wojtek on function, JavaScript · · Comments · 1 min read

In my last project I needed a function in JavaScript that will execute itself as soon as it’s ready. My first idea was something like that: // declare function function myFunction() { alert('Hello world!'); } // run it when DOM is ready with help of jQuery $(document).ready(function() { myFunction(); }); but in the back of my mind I knew there is... Read more »