For years I've always written IIFEs like this:
(function () {
console.log("hi");
})();
but I recently came across one like this with the last two brackets inside the final one:
(function () {
console.log("hi");
}());
I assumed it wouldn't work, but surprisingly it does. This, however, obviously doesn't:
function () {
console.log("hi");
}();
Why is this? The two working versions seem to do the same thing, but is there a difference?