Possible Duplicate:
JavaScript scope and closure
Why should I (or shouldn't I) do this...
<script type="text/javascript">
(function() {
alert("Test");
})();
</script>
Instead of this...
<script type="text/javascript">
alert("Test");
</script>
What is the first approach called, and what are the benefits/drawbacks? I assume this has something to do with the execution, but I'd like to know more.