Javascript file as an anonymous function

Posted by Andrew Kou on Stack Overflow See other posts from Stack Overflow or by Andrew Kou
Published on 2010-03-11T01:20:01Z Indexed on 2010/04/04 17:13 UTC
Read the original article Hit count: 650

Filed under:
|

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?

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about coding-style