I am debugging someone else\'s JavaScript code and a majority of the code is wrapped like this:
(function ($) {
//majority of code here...
})(jQuery);
>
This structure is called JQuery Plugin, purpose of the plugins is to create a framework of any common task/function in your project, same-way you can extend your plugins according to your usage in different page or in same page. that way you can avoid repeating the same code everywhere.
check it out http://docs.jquery.com/Plugins/Authoring