Would like some clarification on using $(this) (code example provided)

Would like some clarification on using $(this) (code example provided)

Hello,

Here's a funky demo page.

Here's my funky code:

  1. $(document).ready(function() {
  2.    
  3.     var $this = $(this),
  4.    
  5.     $dog = $('#dog'),
  6.    
  7.     billy = function(num) {
  8.        
  9.         console.log('(billy ' + num + ')', 'this:', this, '$this:', $this, '$dog:', $dog);
  10.        
  11.     };
  12.    
  13.     billy(1);
  14.    
  15.     $('#clickme').click(function() {
  16.        
  17.         console.log('(1)', 'this:', this, '$this:', $this, '$dog:', $dog);
  18.        
  19.         var $this = $(this);
  20.        
  21.         console.log('(2)', 'this:', this, '$this:', $this, '$dog:', $dog);
  22.        
  23.         $('#what').animate({
  24.            
  25.             opacity: 0.25,
  26.             left: '+=50',
  27.             height: 'toggle'
  28.            
  29.         }, 500, function() {
  30.            
  31.             console.log('(3)', 'this:', this, '$this:', $this, '$dog:', $dog);
  32.            
  33.             var $this = $(this);
  34.            
  35.             console.log('(4)', 'this:', this, '$this:', $this, '$dog:', $dog);
  36.            
  37.         });
  38.        
  39.         billy(2);
  40.        
  41.     });
  42.    
  43. });

My question(s):

When I have nested closures/functions/other, where each has its own "this", should I be worried about re-defining "var $this = $(this)"?

In other words, when you need to create a cached version of $(this), and there's multiple nested levels of closures and functions, is it best practice to use different variable names for $(this)? Like $this1, $this2, $this3 (and so on).

Sorry if noob question. I was just working on some code recently where I was using the same variable name for all my "this" (i.e. $this = $(this)) and that got me worried that maybe doing so would cause some strange bugs in my code down the road.

Anyone know of any articles that cover this (I found some articles on jquery and this, but nothing that covered my exact question above). Does anyone have a rule of thumb for handling multiple levels of "this"?

TIA!

Cheers,
M