Developing page apps on browsers (Safari, Chrome, and Firefox) or building HTML-based Web-view native apps, like PhoneGap, is a good choice for you to use Zepto.
The difference between jquery and Zepto
Since I didn't use Zepto, I first tried the difference between jquery and Zepto.
1:$ (function () {}); J,z general, the page loaded complete execution callback function (Zepto in $->zepto), of course, can be omitted
The source can not understand the place summary
1: Speaking from this = = = void 0
second, why not directly with undefined undefined in JavaScript does not belong to the reserved word /keyword, so in IE5. 5We can assign a value to it as a variable (ie9+ and other modern browsers will be invalid for undefined)var undefinedbackup =1 ; // Show "undefined"console.log (typeof undefinedbackup); // Show "Number" in Ie5.5~8, "undefined"console.log (typeof undefined) in other browsers;
The action of Void of three or one-tuple operator Void is characterized by:1no matter what the operand after void is, return to the pure undefined;2. Void takes a value operation on subsequent operands, so if the property has a getter function, then the Getter function is called (which can cause side effects)varArticle ={_view:0, Getview () {Console.log ( This. _view); return This. _view++; }};varTest =voidArticle.view;//showing 0Console.log (test);//Show undefinedConsole.log (Article._view);//showing 1One of the behavior characteristics of delete, which is compared by the unary operator delete, is that its operand is not evaluated (the other behavior features of delete are much more complex than we thought, and are not documented in detail here)varArticle ={_view:0, Getview () {Console.log ( This. _view); return This. _view++; }};varRET =Delete Article.view;console.log (ret);//Display TrueConsole.log (Article._view);//showing 0
2: The 5 ways to add getter and setter to JS object and how to make object properties non-configurable or enumerated
define getter and setter1the object initializer is specified when creating an object (also known as declaring when an object is created by literal value) (function () {varo ={A:7, GetB () {return This. A +1;},//Indirect modification of a property by Get,set's B,c method SetC (x) { This. A = x/2} }; Console.log (O.A); Console.log (O.B); O.C= -; Console.log (O.A);}) (); In Chrome, debug the view as follows: You can see the object is much lower.GetProperties, andSetThe result of the property output is as follows:GetStatement andSetstatements can be declared multiple times to correspond to multiple getters and setters the benefit of using this method is that the corresponding getter and setter can be declared at the same time as the attribute is declared. Here is someone asking, can you put the O objectGetAndSetThe method names of the methods are changed to "a" so that the "." can be passed directly. To access the method direct operation (function () {varo ={A:7, GetA () {return This. A +1;},//dead Loop SetA (x) { This. A = x/2} }; Console.log (O.A); Console.log (O.B); O.C= -; Console.log (O.A);}) Open Chrome View the created view as follows: You can see this time.GetAndSetThe method has been different from the above, but whether it can really play a role, the answer is no, when we call through O.A is a Get statement declaration of a method, entered into the method after encountering ThisThe. A method continues to call the method to form a dead loop that eventually results in a dead loop memory overflow error.
3:throw New TypeError ()
New TypeError () will throw a red-letter error, and the subsequent code will continue to execute!
4:this.length>>>0 is generally used to ensure that the this.length is an operational value.
Unsigned right shift operation >>> unsigned Right shift operator consists of three greater than sign (>>>) indicates that it will be unsigned 32all digits of the number of digits are shifted to the right. For positive numbers, the result of an unsigned right-shift operation is the same as a signed right-shift operation. Using the example of a signed right-shift operation,64 move right 5 bit and change to 2:varIOLD = 64;//equals binary 1000000varINew = IOld >>> 5;//equals binary 100 binary 2for negative numbers, the situation is different. Unsigned right-shift operation0fills all vacancies. For positive numbers, this is the same as a signed right-shift operation, and a negative number is treated as a positive number. Because the result of an unsigned right-shift operation is a32-bit positive number, so the unsigned right-shift operation of negative numbers is always a very large one. For example, if you move 64 to the right 5 bits, you will get 134217726. How do we get this result? To do this, you need to convert this number to an unsigned equivalent (although the number itself is still signed), you can obtain this form by using the following code:varIUNSIGNED64 = -64 >>> 0and then, with the number type toString (), gets its true bit representation, using the base of2: Alert (iunsigned64.tostring (2) ; this will generate11111111111111111111111111000000, which is the binary complement representation of the signed integer-64, but it equals the unsigned integer 4294967232. For this reason, use the unsigned right-shift operator with caution.
Try reading Zepto source code