jQuery stuff I haven't seen before; jQuery(this) and ;(function($) { ... })(jQuery)

jQuery stuff I haven't seen before; jQuery(this) and ;(function($) { ... })(jQuery)

I'm working with a jQuery plugin, and it has some unusual coding that I think might be kinda old school. For the sake of my own education, I'm hoping you guys and gals can give me some clarification.

First, I see this:

  1. var $elem = jQuery(this);

I've never seen jQuery(this)... is it the same as $(this)? I did some tests and they appear to be the same, but later in the script the author uses $(this)... so why did he use jQuery(this) in one part and $(this) later?

And is there a reason he used $elem instead of just elem?


Second, I see a function like this:

  1. ;(function($) {
  2.       var foo = {
  3.             bar : 'a',
  4.             example : 'b'
  5.       }

  6.       function whatever(event) {
  7.             ...
  8.       }
  9. })(jQuery);

I've never seen ;(function($) { ... })(jQuery), what's the actual purpose of this? There are several other variables and functions in it, I just abbreviated it here for the post.