Why do many javascript libraries look like this:
(function () {
/* code goes here */
})();
It appears to define an unnamed function whic
var $={} // a name space is defined
(function($) {
$.a_variable="some vale"
var b_variable = "some more value";
})($);
$.a_variable // acess it like this.
now any thing inside anonymous function has scope equal to that function only also we can create objects that may act as properties to our name space.