function
Self executing function in JavaScript
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(