I was just going through the code of timer.js, playing around with the dev tools in Chrome, and basically I call the plugin like so:
var timer = $.timer(function(){
$('#add-html').html('Hello There !!');
});
timer.set({ time:5000 , autostart :true });
Even the demo uses the same example, now when the below line executed:
var timer = $.timer(function(){
$('#add-html').html('Hello There !!');
});
This line inside the plugin executes and returns this
, but what is return this
at this point? Is it an instance of the whole plugin? Or what is it exactly, I know without it an error is thrown, but what exactly is return this
used here for and what is its value
?
I use return this
a lot for chaining etc in JavaScript, but somehow I am not able to understand the contextual usage of the return this
here. Would anybody explain ?