Javascript file as an anonymous function
- by Andrew Kou
I have been reading a lot of Javascript lately and I have been noticing that the whole file is wrapped like the following in the .js files to be imported.
(function() {
...
code
...
})()
What is the reason for doing this rather than a simple set of constructor functions?