Should You Use the ‘var $this = $(this);’ Syntax in jQuery?

A common jQuery coding practice
 var $this = $(this);

 There are a few benefits: 

  1.  $(this) is only evaluated once (minor efficiency) 
  2. You can use a more descriptive name for $(this). I’m using var $MyCurrentBook = $(this); 
  3. By preceding the variable name with the $ sign, you’re reminding yourself that it’s a jQuery variable, not just a plain old JavaScript variable.

Comments