Common js Problems

Source: Internet
Author: User
Js FAQ case-sensitive single quotes, which are used to single quotes in double quotation marks-js. -The attribute value of html must be enclosed in double quotation marks. -Single quotation marks can contain double quotation marks, which can also contain single quotation marks. Brackets can be separators or expressions. -(Function... SyntaxHighlighter. all ();

Common js Problems
Case Sensitive
Single quotation marks, double quotation marks
-Single quotes are used in js.
-The attribute value of html must be enclosed in double quotation marks.
-Single quotation marks can contain double quotation marks, which can also contain single quotation marks.
Brackets
-It can be a separator or expression. As follows:
-(Function (){})()
-The onload function is loaded when the entire page is loaded. (If there are many images, it will be very slow. You can rewrite the window. onload function to execute the function at the same time when loading the text)
Function call and reference
Var foo = functionName ();
Var foo1 = functionName;
The former indicates the return value of the function, and the latter indicates a reference to the function. For example, window. onload = functionName;
Newline
One line in js is the default statement and cannot contain a forced line break. If you want to wrap a line, you can add a backslash at the end of the line or use a string connector +. We recommend that you use the latter.
Semicolon and braces (optional)
The semicolon can be left blank, but we recommend that you add it for code readability.
Heavy Load
Js does not support overloading. If two functions have the same name (not related to parameters), the following functions will overwrite the above functions.
If function alert () {}; appears in the Code, the core function alert is overwritten.
Therefore, do not use the name of the core function when naming a function.
Scope and Closure
Scope: the code space that has access permissions to a property or method.
Closure-an internal function can access the attributes of an external function even after the external function is executed and terminated.
The related code is as follows:

 

====================================




New Document




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.