Different ways of defining self-executing javascript anonymous functions

47 Views Asked by At

I'd like to know if there is any difference when defining self-executing functions in the following ways:

var f = (function(){
    return function(){
        document.getElementById("f").innerText = "Hello f";
    };
})();

var g = (function(){
    return function(){
        document.getElementById("g").innerText = "Hello g";
    };
}());

var h = function(){
    return function(){
        document.getElementById("h").innerText = "Hello h";
    };
}();

They seem to give the same result. Please see http://jsfiddle.net/sosegon/nj4ttnmu/

BR, SV

0

There are 0 best solutions below