I'm new to JavaScript and am trying to modify a weblist template I purchased and in a certain way There is a little problem in understanding that the variable is being declared / used.
The template has direct content contents such as the jquery level declared:
window.theme = {}; (Function (theme, $) {// function}). Apply (this, [window.theme, jquery]);
Then they start like this example in a separate file:
(function ($) {'strict use'; if ( $ .frunction ($ .fn ['ThemePlugin Antim']) {$ (function () {$ ('[data-plugin-animate], [data-manifest-animation]'). Each (function () {var $ This = $ (this), opts; var pluginOptions = $ this.data ('plugin-option'); if (plugin option) opts = pluginOptions; $ this.themePluginAnimate (opts);});});}}) (It's [jQuery]);
I'm confusing:
var $ this = $ (this), opts;
This is my understanding of googling This is the way to work with a comma operator:
$ (this) = opts; $ this = $ (this);
My In the brain, the opts
has not been started, so why is it being used as an assignment? This pattern is on every module, so I want to understand it before starting the change. / P>
I found some goals while trying to find that if var = opt
was declared, it would have been.
Can anyone tell me what is happening here?
If I understand you correctly, then you need to explain that javascript init variable is the most First, when you read Javascript code - running all the variables at the beginning of the function:
function () {var a = 1; Console.log (a); // 1 console.log (b); // undefined var b = 2; }
will look like JS:
function () {var a, b; // First we declare variable A = 1; Console.log (a); // = & gt; 1 console.log (b); // = & gt; Undefined B = 2; }
But there is a higher priority in declaring another function, so why not take it first:
function () {console.log (Func) // = & gt; Function () {return1;} console.log (a) // = & gt; Undefined var a = 1; Function Fun () {return1;}}
And what actually happened:
function () {Function Fun () {Return 1;} // First of all functions; // Secondary Variable console.log (func) // = & gt; Function () {return1;} console.log (a) // = & gt; Undefined one = 1; }
This is a little theory for you, because I think you will find something in this way in the code in the near future.
And now lets you check the code:
var $ this = $ (this), opts;
And how did Javascript read it?
var $ this, opts; // declared all the variables; $ The = $ (this) // init variable $ this
If you were confused with ,
, then there are delimiters between the variables that you declare Are:
var a, b, c, d;
equals:
var a Var B; Var C; Var D;
Good luck!
No comments:
Post a Comment