JS of the relevant knowledge content

Source: Internet
Author: User

I. The closure concept in JS

  Code Model: (function () {*******//inside is the code that writes the specific function *******}) ();

The effect of parentheses:

A. The first is to represent the role of code segmentation;

B. The second is to represent an operator that indicates the function it is going to run (for example, the last parenthesis in the upper line of code indicates the meaning of the run);

Second, how to create your own JS Library

The Code template is: (function () {

function $ () {

Code

}

window[' IC ']={}; Window[' namespace ']={} namespace

windwo[' IC ' [' $ ']=$;

})();

Three, JS FAQ

1. JS is case-sensitive;

2. js in single quotation marks, the difference between double quotation marks (single quotation marks can have double quotes, double quotation marks can have single quotation marks, single quotation marks in the use of the escape character "\");

3. The effect of parentheses is two, one is the function of the segmentation code, the other is the operator, the function of executing functions;

4. The difference between a function invocation and a reference;

var too = example (); Assign the example function return value to the too variable.

var too = example; Assign a example function pointer (a reference to a function);

5. Line break, "\", does not appear in the browser, the role of newline. The other is to connect with the "+" number connector;

6. Optional rules for semicolons and curly braces; (after each line ends with a semicolon);

7. Overloading, JS is not support overloading, when two the same function is, only load the last function of the code content to overwrite the previous function;

8. The problem of scope and closure in JS; (Closure: is a scope-related concept that refers to an intrinsic function that can still access the properties of its external function even after execution of the external function has completed and terminated)

JS of the relevant knowledge content

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.