javascript: what are immediate functions used for [duplicate]
- by tkoomzaaskz
This question already has an answer here:
Why using self executing function in JavaScript? [duplicate]
4 answers
I've been programming in JS since some time, but I have never came upon a need of using immediate functions, for example:
(function(){
console.log('hello, I am an immediate function');
}())
What would be the difference if I just wrote:
console.log('hello, I am an immediate function');
? I don't have any access to this function anyway (it is not assigned anywhere). I think (but I'm not sure) that I can implement everything without immediate functions - so why do people use it?