Add or remove objects
Function rect (W, h) {This. width = W; this. height = H;} var r = new rect (2, 3);/* Add a calculated area to the r object method area () */R. area = function () {return this. width * This. height}; alert (R. width); //
If (...) {...} else if (...) {...} else {...}
Switch (...) {Case A:... break; Case B:... break; Case C:... break; default:... break ;}
While (...) {...} Do... while (...); for (I = 0; I
With (..){...}
Throw new error (
You can use single or double quotation marks.
Alert ("in case of 'delphi 'blog"); // In case of 'delphi 'blog alert ('in case of "Delphi" blog'); // in case of "Delphi" blog
Escape characters
/* X and \ U are two-digit and
Numeric type variables and numeric object variables
VaR N, N; n = new number (123); // numeric object variable n = 321; // numeric type variable, you can also use the number class method alert (N ); // 123 alert (n); // 321
We often use dynamic loading of JavaScript. It is easy to write a function. We have also written a function before. However, when loading multiple JS files, we can load them successively according to the order returned by the browser, this is
Jslint is a javascript verification tool (www.jslint.com) that can scan JavascriptSource codeTo find the problem. If jslint finds a problem, jslint will display a message describing the problem and point out the error in the sourceCode. Some
JS minifier is a tool used to filter comments and useless spaces in JS files. You canHttp://fmarcia.info/jsmin/Download its web version. You can also get other information at the bottom of the http://javascript.crockford.com/jsmin.html pageProgram.
I read the book "MVC-based JavaScript web rich Application Development" and admire more advanced JavaScript applications. Compared with the previous use of JavaScript for verification, interface, and other functions, this book explains from
ArticleDirectory
1. What is an anonymous function?
Ii. Differences between function literal and function () constructor
Iii. Code mode of anonymous Functions
Iv. Application of anonymous Functions
You can understand multiple
Complete example: examples of using objects and inheritance
// Parent class exampleFunction parent (students, teacher ){// Public MemberThis. Name = teacher;This. Students = students;This. Teacher = teacher;// Private member// _ Special variables of
Only numeric amounts can be entered in the restricted input box(Event. keycode 57) event. returnvalue =False; ">
1. oncontextmenu = "window. event. returnvalue = false"Bottom shield right-click NO Available for table2. CancelSelect and prevent
Promotion and so on control the Javascript file displayed by the ad and the Javascript in the source file of the generated ad unit
Code All are processed by JS compressors and obfuscators. To reduce the size of these files.
When we need to
We all know that JavaScript is an interpreted language executed in the client browser. In other words, JavaScript will be downloaded to the browser in plain text, and then the browser will execute this JavaScript as neededCode.
You only
Recently, the Javascript script -- greasemonkey! The script developed by "Shaun friedle" can easily handle CAPTCHA of the Megaupload site. If you do not believe this, go to http://herecomethelizards.co.uk/mu_captcha/and try it yourself! Now, the
1. automatically select text in the text box
2. input box restrictionsOnblur = "If (this. value 12){Alert ('month input is incorrect! ');This. Focus () ;}>
3. Only numbers can be entered in the restricted input box. 57) event. returnvalue =
Array direct quantity
VaR arr; arr = ['A', 'bb', 'cc']; alert (ARR. tolocalestring (); // AA, BB, ccarr = [11, 22, 33]; alert (ARR. tolocalestring (); // 11.00, 22.00, 33.00/* the array element can be of any type, including the array itself
Unlike other classes, math is not created
Cube Method (New Math () cannot be used in this way. All its methods are static (names must be called ).
Math. ABS; // absolute value math. max; // the math of the two numbers. min; // The small
JS Code can be in the head or body area, but there are some differences.
JS is loaded in sequence with other elements on the webpage. After loading, a syntax check is performed first and then executed sequentially;
If JavaScript does not contain the
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