Query the introduction of JS:
1. Logic or operator |:
When the operator | is a Boolean value, it performs a Boolean OR operation on the two operators.
It calculates the first operation number first. If the value of this expression can be
Body
The concept of closure:
A closure is an expression (usually a function) that has many variables and is bound to these variables. Therefore, these variables are part of the expression.
The most common Closure
CopyCodeThe Code is as
I. character classes
Concept:Put the Individual Direct character in square brackets to form a character class ).
Note:Red indicates that it is not particularly clear
[...] -- Indicates that any character in the character class meets
[^.
1. Use JavaScript to implement classes
Javascritpt does not have a special mechanism to implement classes. Here we use its function to allow nesting mechanisms to implement classes. A function can contain variables and other functions. In this way,
CopyCodeThe Code is as follows: function FN ()
{
For (VAR I = 0; I Alert ("th" + (I + 1) + "parameter value:" + arguments [I]);
}
}
VaR STR = ' {Ni} ';
Str. Replace (/\ {([A-Z] +) \}/ig, FN );
According to multiple tests, the output result
In the Javascript design pattern, this method is described in detail to implement chained call of methods, you only need to let the methods defined in the prototype return the reference of the Instance Object that calls these methods.Code:
Copy
Function:
CopyCodeThe Code is as follows: function throttle (FN, MS ){
VaR last = (new date (). gettime ();
Return (function (){
VaR now = (new date (). gettime ();
If (now-last> MS ){
Last = now;
FN. Apply (this, arguments );
}
});
}
1. Object impersonating Principle: The constructor uses the this keyword to assign values to all attributes and methods (that is, the constructor method of class Declaration ).
Because the constructor is just a function, you can make the constructor
In JavaScript
Code It is only reflected in one form, that is, function.
Note: The above words are in lower case. Do not confuse them with JavaScript built-in functions such as number, String, object, and function. The javascript language is
1. Create a script block ProgramCode
Copy code The Code is as follows:
2. Hide the script code Program code[Ctrl + A select all Note: If you need to introduce external JS, You need to refresh it to execute]
Related code will not be executed in
Code As follows:
Copy code Code: var BR = {};
BR. eventrouter = {};
BR. eventrouter. addlisten = function (El, eventtype, func ){
If (! El. eventobjs ){
El. eventobjs = {};
}
If (! El. eventobjs [eventtype]) {
El. eventobjs [eventtype] = [];
BR.
You can see this method in some JavaScript libraries:
CopyCode The Code is as follows: (function (){
// Code of all databases
})();
To be honest, I am a beginner of Js. This is too scary. In these JS libraries, this function basically includes all
In the past, JavaScript was weak in Io support, so it could not be written into the corresponding text file, and the error of the exception object was not uniform, so the detailed stack could not be printed. The custom exception object is a very
When the understanding and practical ability of Lou pig are still insufficient, I copied a lot of things written by Li Zhan in my blog as a "knowledge reserve ". This time is still not vulgar. When turning to Chapter 2, I was deeply attracted and
Just now, we suddenly had a chance to traverse the iterator directly with silly next. Why must we implement this silly next? Directly implement each. In this way, yeah and Yitong write the first ultra-Concise version in a short time:CopyCodeThe Code
CopyCode The Code is as follows: var OBJ = new object ();
OBJ. triggeronce = function (FN) {// control the function to be triggered only once
Return function (){
Try {
FN. Apply (this, arguments );
}
Catch (e ){
VaR TXT = "There was an error on this
Name
Free or not
Whether multiple types of output are supported
Gorgeous Interface
Functionality
Construction framework
Ejschart
No
Yes
Yes
Upper
None
Jschart
Free for individuals
But I often use JavaScript, so I need to understand the concept here.
In fact, the closure concept in Javascript is very simple, that is, the function uses external variables and can be obtained without passing parameters.
For example:
CopyCode The
How does js complete a normal animation? Let's take a look at the example.
Copy codeThe Code is as follows: setInterval (function (){
Element. style. left = parseFloat (element. style. left) + (n) + 'px ';
}, 10 );
Test [Ctrl + A select all Note: If
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service