premises
Through the recent learning of JavaScript video, a new function-anonymous function-is also exposed to a new noun--closure--by learning something fresh. Let's start with the basic anonymous function. One, anonymous function
Anonymous
1. The method of slowing movement back to the top (mostly with this):
var totop = document.getElementById ("Totop");
var target = 0;
Totop.onclick = function () {
clearinterval (timer);
var timer = setinterval (function () {
target =
Before invoking a JavaScript method, a lexical analysis of the method is performed, mainly by analyzing the following:
First step: Analyze parameters First
Second cloth: Re-analysis variable declaration
Step Three: Final analysis function
Factory mode, which produces different objects according to different parameters; One of the design patterns in 23
Demand: Produce different mobile objects
var P1 = {
Color: "White",
CPU: "4 Cores",
Size: "5.5"
};
Batch production object,
1.innerText is the text in the closed label with ID object, and the input output is the escape text (string);
(Label control is valid with innertext)
2.innerHtml is the text inside the tag, input output to the DOM inside pure HTML code (stream);
(
For this problem, there may be a page in Chinese garbled, it may be pop-up window Chinese garbled. Online search solutions are as follows: to encode, and then to plus a charset, where the two coding formats must be synchronized.
In fact, in my
T checks that the user registration information is correct, does not meet the Times error in the following situations, and prevents the submission of the form:
The username must be 3-10 English letters or numbers;
The password must be 6-20
Reproduced from: http://www.css88.com/archives/7052
Issue 1: Scope (scope) (function () {var a = b = 5;}) (); Console.log (b); What the console (console) will print.
The code above will print out 5.The pitfall of this problem is that there are two
Go before and after spacefunction Trim (s){Return S.replace (/^s*/, ""). Replace (/s*$/, "");}if (!/^w{4,25}$/.test (username)){Errstr + = "Your username must be letters and numbers, and the length is between 4 and 25";}if (!/^w{4,25}$/.test (pass)){
JavaScript Object-Oriented code example
Create a constructor for a site whose parameter name and URL are
function Site (name, URL)
{
This.url = URL;
THIS.name = name;
}
Add a method for site to display the URL
Site.prototype.show = function
In JavaScript scripts, local functions have the same name as the perimeter function, which overrides the extranet function, where the variable can be repeatedly defined.
See the example below.
A = function () {
var me = this;
Me.method1 =
The factory model is a well-known design pattern in software engineering, which abstracts the process of creating concrete objects. Given the inability to create classes in ECMAScript, developers invented a function that encapsulates the details of
From about 09 onwards, MVC gradually shine in front of the field, and finally in the past 2015 with the introduction of react native ushered in a major outbreak: Angularjs, Emberjs, Backbone, Reactjs, Riotjs, Vuejs ... A series of names have come
Before reading "JavaScript Advanced Program Design", saw the lable statement, at that time feel like rarely used, but today, just at the project finally to the right scene, reasonable use of label can greatly optimize performance.
First, let's
Below is reprint
Xmlhttprequest.send ()Send an HTTP request
GrammarSend (body)If the HTTP method specified by calling open () is a POST or put,body parameter, the request body is specified as a string or Document object.
This parameter is null if
The Promise object is used to represent the final state (completion or failure) of an asynchronous operation and the value it returns.
Grammar:
New Promise (function (resolve, reject) {...}/* executor * );
Parameters:
Resolve and reject two
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