I was looking for a solution to a problem and I found this aswer https://stackoverflow.com/a/6962808/2724978
The function written is:
(function loop() {
var rand = Math.round(Math.random() * (3000 - 500)) + 500;
setTimeout(function() {
doSomething();
loop();
}, rand);
}());
My question is, why is the function insite parenthesis an also having () at the end? It got me a bit confused, never seen this before.