I read the beginning of jQuery2.1.x and the beginning of jQuery2.1.x.
I haven't written a blog for a long time. I don't forget this habit, but I have been experiencing technological transformation in the past year and a half. So the technology on. NET is not too deep.
Since returning to fanke again, I have transformed from a. NET engineer with 3 years of development experience to a front-end (H5. I will not go into details about the transformation in this blog!
Since last May, I have considered myself an absolute newbie, starting with the most basic and original technology (HTML, CSS, DIV layout, PS cut graph, javascript, etc ).
Now, we are still learning. JQuery source code learning, I always think it is necessary, not how familiar it is to use, of course, the source code is familiar, it is just a matter of course. The process of learning jQuery source code is a process of deep understanding and deep learning of javascript, which is very important.
I am not planning to write too many details about jQuery in this blog series, but to find out what I think is interesting during my learning process, I would like to share with you some of the parts that can deepen your understanding of javascript. If Daniel is passing by, please feel free to accept and improve it.
I chose the latest version of jQuery2.1.4 for learning (Version 3.0 has not been officially released), because it saves some complicated compatibility code and makes jQuery more clear.
This series of blogs will refer to the book jQuery technology Insider: in-depth analysis of jQuery architecture design and implementation principles, and the jQuery official website. I will try more code practices to record the blog.
I. The rough skeleton is as follows:
(function(global, factory) { if (typeof module === "object" && typeof module.exports === "object") { module.exports = global.document ? factory(global, true) : function(w) { if (!w.document) { throw new Error("jQuery requires a window with a document"); } return factory(w); }; } else { factory(global); } }(typeof window !== "undefined" ? window : this, function(window, noGlobal) { //... }))
Here is a major javascript point: anonymous function Self-call or self-execution. The purpose of this encapsulation is to meet Commonjs specifications, but I think it is useless. Currently, seajs can well meet the requirements by absorbing the advantages of AMD and Commonjs.
Furthermore, I believe that modularization will become a standard. Just like HTML5, many attributes and effects no longer need JavaScript to be implemented.
There are many writing methods for anonymous function Self-calling or self-execution. I will list some of them as follows:
(function(){console.log(1);})(); (function(){console.log(2);}()); !function(){console.log(3);}(); +function(){console.log(4);}(); -function(){console.log(5);}(); ~function(){console.log(6);}(); void function(){console.log(7);}(); new function(){console.log(8);}();
Let's start with this article!