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

Popular posts from this blog

CSS Browser detection using jQuery instead of hacks

மோசடிகளால் ஏமாறாமல் பாதுகாப்பாக இருங்கள்!

Ace Your Interview with These Commonly Asked Redux Questions! 🌟