can variables be declared directly with this keyword ??
guys i a few questions about the code in the below pluggin :
now if you check line 15 to 25 . see how the variables are declared :
- this.element = element;
- this.$element = $(this.element);
-
- this.options = $.extend( {}, defaults, options) ;
-
- this._defaults = defaults;
- this._name = pluginName;
-
- this.init();
I taught in JS/jquery u had to declare a variable before you could access it with "this" keyword. ? or am i wrong ? also what is the author trying to achieve with this piece of code :
- this.element = element;
- this.$element = $(this.element);
i mean the value passed to the function Plugin
is stored in this.element in the 1st line , now why on the 2nd line is the author adding another variable this.$element and passing the value of $(this.element) to it . ? what's the purpose ?