JavaScript notes (1)

Source: Internet
Author: User
Tags arithmetic operators

1. The defer property in script is set to "defer", which means that the text does not represent any document content, so the browser can process the remainder of the page in advance and process the script section when the page is processed and ready to be displayed. (The defer property can increase the speed of page loading)

2. Keep the script location consistent, either all in the head element, or all at the very end of the BODY element.

3. The onload event of the BODY element, which triggers the event at the end of page loading, is the function that invokes the mapping.

4.onclick triggers when the mouse clicks on an element
onMouseOver triggered when the mouse hovers over an element
onmouseout triggers when the mouse leaves an element
onfocus triggers when an element receives focus
onblur triggers when an element loses focus

5. In JavaScript syntax, JavaScript functions are also objects, so you can assign a function to a variable or property of another object by name or directly.

6. BOM is the predecessor of the more formal Document Object Model (DOM), sometimes referred to as DOM level 0

7, Propertyoperator (.)
Arithmetic operators (+ and-)
Conditional operators (< and >)

8. The property operator is called by means of the method chain, for example
var tstvalue = document.getElementById ("Test"). style.backgroundcolor= "#fff";
Use the document's getElementById method to access the page element, and then set the background color of the element by accessing the style object.
BackgroundColor is a property of a style object that is a property of the page element, and the page element can be accessed through the getElementById method, and getElementById is also a property of the Document object

9. The rules for variable scopes are as follows:
(1) If you declare a variable using the var keyword in a function or code block, then this is a local variable that belongs to this function or block of code;
(2) If you use a variable that is not declared with the Var keyword, and there is a global variable with the same name, the local variable will be equivalent to the existing global variable.

Therefore, if you use the var keyword to define variables within a function, you can avoid the problem of global variables and local variables in the same life.

10. A variable is simply a reference to a data name.

11, the use of JavaScript files can often improve the efficiency of page loading, because the browser is the first time to load the file cache, referring to the same file will be taken from the cache.

JavaScript notes (1)

Related Article

Contact Us

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

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.