JS Key Summary

Source: Internet
Author: User

1. Get Style
(1) style can only get properties of the inline style
(2) Firefox getcomputedstyle (obj,null) [attr],ie:obj.currentstyle[attr]
2, ready, onload difference:
(1) The trigger of the ready event, indicating that the document structure has been loaded (not including pictures and other non-text media files), the execution time is earlier than onload
(2) the trigger of the OnLoad event, which indicates that all elements, including pictures and so on, are loaded and completed.
3. Closure concept:
(1) How can I read local variables from outside the function? --Define a function inside the function and return to the function.
(2) JS allows the use of intrinsic functions (function definitions and function expressions) in the function body of another function, and these intrinsics can access all local variables, parameters, and other intrinsic functions declared in the outer function where they are located. When one of these intrinsics is called outside the outer function that contains them, a closure is formed.
(3) Read the local variables inside the function, and keep the values of the variables in memory.
(4) Closure Micro Understanding: Define the scope chain, the execution time to determine the execution environment, create the active object, for the active object to add arguments properties, and parameters, function reference.
(5) Definition and execution: The function scope is determined when the function is defined, not when the function is executed.
(6) JS garbage collection mechanism: If an object is no longer referenced, it will be recycled, and if two objects are referenced by each other and no longer referenced by the 3rd, then the two objects referenced by each other will be recycled.
4. Variable Scope
(1) Scope chain lookup rules
(2) No block level scope
(3) The variable declaration will be in advance and the assignment will not advance
(4) Do not use Var are global variables, global variables are window properties
5, function self-execution can be used as a block-level scope
6. The HTML string is converted to a JQuery object, and the jquery object goes with the DOM object.
7. Reference passing and value passing
(1) Basic data types and reference data types
(2) define a special variable in the stack, the value of which is equal to the array or object in the heap memory of the first address (as in the C language), in the stack of this special variable becomes an array or object reference variable. The variables in the stack point to the variables in the heap memory, which is the pointer in Java. A reference variable is actually a pointer to the content in the heap's memory.
(3) Modify the reference variable, and the referenced object will also be modified. If you do not want to change at the same time, b.prototype[i] = Createobject.prototype[i] This cycle opens up new memory space.
8. This point mechanism: in a function context, this is provided by the caller and is determined by the way the function is called. If the call to the left of the parentheses () is the value of the reference type, this is set to the base object of the reference type value, and in other cases (any other property that differs from the reference type), this value is null. However, there is no actual case where the value of this is null, because when the value of this is NULL, its value is implicitly converted to the global object.
9, the operating mechanism of the timer: The loop execution process, almost simultaneously set up 5 timers, in general, these timers will be triggered after 1 seconds, and the output of the loop is executed immediately.

JS Key Summary

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.