Actually this is a cliché question. About this article is very many, in fact, I thought I had already understood it, but yesterday in the process of doing the project, or appeared a trace of doubt, think about before the JavaScript weekly in the
Recently a period of time to see a lot of JavaScript library source code, such as prototype, EXT core and so on. This concept is applied extensively in these libraries. It was not until yesterday that the book "The Return of the JavaScript king" was
Usually we get the event object generally written as follows:
Copy Code code as follows:
function GetEvent (event) {
Return Event | | Window.event//IE:window.event
}
If there are no arguments, it can be written (non ie:
Call Portal
A chained invocation has two entrances to the Async.go method and the Async.chain method, which are essentially consistent, except that the Async.chain method does not provide the initial parameters when invoked, and the Async.go method
The code looks like this:
var arr = [5,32,28,66,2,15,3];
Arr.sort (function (A1,A2) {return
a1-a2;//a2-a1 input Reverse
});
Console.log (arr);
Console.log (Arr.reverse ()); Reverse reverse the order of elements in an array
var arr2
Delivery Callback
One of the first things we have to consider is how to pass the callback entry. In the most traditional xhr invocation, the callback function is passed as the last argument to the asynchronous function:
Copy Code code as
problem
In AJAX applications, calling XMLHttpRequest is a common case. In particular, client-centric AJAX applications, various operations that need to obtain data from the server are completed by XHR asynchronous calls. However, in single-threaded
constants: JavaScript constants, also called Literal constants, are the information that is solidified in program code.
variables: The main function of a variable is to access data, providing a container for accessing information.
var x = "XX";
y = "xxx";
Such. There's a problem here, for example, in a line in the code, I would like to use a declared variable x, the result of typing or spelling errors, the variable is written y, the result is equivalent to "implicit" declared
This article focuses on the first reason. Finally, a development pattern is given to replace the traditional loop structure, which can completely avoid the situation that the script is out of control.
Original title:Speed up Your JavaScript, part 1
1, reference
A reference is a pointer to the actual position of the object. Look at the following examples of using references:
[Ctrl + A All SELECT Note: If the need to introduce external JS need to refresh to perform]
Splice in JavaScript is primarily used to manipulate arrays in JS, including deletions, additions, replacements, and so on.
Note: This method will change the original array!.
1. Delete-To delete the element, two parameters, the first argument (to
Copy Code code as follows:
function Get_cookie (name) {
var start = Document.cookie.indexOf (name+...= ...);
var len = start+name.length+1;
if ((!start) && (name!= document.cookie.substring (0,name.length)) return null;
if (start = =
A bad time to answer, especially undefined, because this involves the realization of the principle of undefined. So, after thinking carefully, write down this article, please heroes to shoot bricks.Total known: null = = undefinedHowever: null!==
1. Writing JS functions
2. HTML element to show/hide plus id attribute
control the show/hide of this TR
3, add buttons, links, etc trigger JS function
Show/Hide
JavaScript shows hidden layers Advertising
Two: JavaScript controls
Copy Code code as follows:
Here are some of my share, I love programming, hope to be able to pay more programming enthusiasts, if you are also one of them, then please add friends, we pay attention to, the following article is that they feel
Front.
As a common application of the date object in JavaScript, the simple calendar is widely used, this article will explain the realization of the simple calendar in detail.
Effect Demo
HTML descriptionUse the two input of type=number as the
Ways to add a function
function addevent (node, type, listener) {
if (Node.addeventlistener) {
The method of the Consortium (DOM method)
The false meaning in the following statement is for the bubbling phase, and if true is for the capture phase (ie
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