Quantcast
Channel: What is the reason for var $this = this - Stack Overflow
Viewing all articles
Browse latest Browse all 7

Answer by Justin Niessner for What is the reason for var $this = this

$
0
0

In this case, nothing. $this is just another variable declaration which has this assigned to it.

Typically, I've seen this shortcut used by people using JavaScript libraries when wrapping this. For example, typical usage in jQuery would be:

// rather than writing $(this) everywherevar $this = $(this);$this.each(function(){    // Do Something});

Viewing all articles
Browse latest Browse all 7

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>