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

What is the reason for var $this = this

$
0
0

I'm not the best at jquery and I came across a var initialization that I don't know why the person who wrote the code did it this way.

In the init for a plugin, we have

this.init = function(settings) {    var $this = this;    this.s = {        initialSlide: 0,        firstSlide: true,    };   ... more code, some uses $this, some uses "this"}

So what is the difference here between "$this" and "this" and why not use one or the other all the time?


Viewing all articles
Browse latest Browse all 7

Trending Articles





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