• Ahh - well, in the root scope:

    function f() { /* do something */ }
    setInterval(f,intervalTime);
    

    is slightly less efficient than this:

    setInterval(function(){ /*do something*/ },intervalTime);
    

    As the first has to also define a named variable for the function.

    However,

    function f() { /* do something */ }
    function onInit() {
      setInterval(f,intervalTime);
    }
    

    Is definitely more efficient than:

    function onInit() {
      setInterval(function(){ /*do something*/ },intervalTime);
    }
    

    as the function only exists in memory once. In that last example, it exists in onInit, but after onInit is run, there's another copy in memory.

    Again, that's something that could potentially be changed in the future though - it could just re-use the same characters.

About

Avatar for Gordon @Gordon started