ecometer

Use anonymous functions

(Development)
#38

JavaScript allows for anonymous functions, and these should be used whenever possible without putting the project’s maintainability at risk. This way, the interpreter no longer needs to resolve the function’s name.
Be aware that this is only good practice when the function is used once. Any function used more than once should be named.

Instead of:

(function(){
    function invokeMe() {
    /*code*/
    }
    setTimeout(invokeMe, 5);
})();

write:

(function(){
    setTimeout(function(){ /*some code here*/ }, 5);
})();
This best practice should only be applied if it is coherent with your project's specifications.
Under CC-By-NX-SA license