JavaScript is case-sensitive: Variables and functions are case-sensitive in JavaScript, for example:
Copy Code code as follows:
function MyFunction () {} and
function MyFunction () {} is different
The core objects array, object, and so on in JavaScript are case-sensitive.
Single and double quotes: The problem is that when you're learning SQL Server concatenation string "SELECT * from page where name= ' Lida '" There is a question: "Is the bottom of the three" double quotes before or single quotes in front? Learned a lot. Know that double quotes are used by the programming language, and single quotes are SQL Server-marked string types. However, there is no special difference between single and double quotes in JavaScript to create strings, but in general JavaScript uses single quotes, and HTML and other attribute values must use double quotes; single quotes can include double quotes, and double quotes can include single quotes ; the escape symbol "\" is required in special cases, for example:
Copy Code code as follows:
var temp= ' <p class= "Namea" >what\ ' s this? ';
The function of parentheses: Like any other language, parentheses in JavaScript are also two functions, one being used as delimiters, such as: (1+1) *2; the second is an expression, for example: (1+1) *2; the second action is an expression, for example: (function () {}) () The parentheses that are separated in are delimiters, followed by parentheses to indicate the method of execution.
Calls and references to functions:
Copy Code code as follows:
var temp=myfunction ();
var temp=myfunction;
Because parentheses can represent execution, the first temp represents the return value of the MyFunction function, while the second temp represents assigning MyFunction to temp. For example:
Copy Code code as follows:
<script type= "Text/javascript" >
JavaScript Document
(function () {
function $ () {
Alert ("Is buffering! ");
}
window[' LD '] = {}
window[' LD ' [' $ '] = $;
}
)();
Window.onload = ld.$;
</script>
The Web page can load normally, because this means that the $ method is assigned to the Window.onload, the page is loaded to run the $ () function written by itself; If you change this sentence into
window.onload=ld.$ () The results of the operation are as follows: First, the buffering is displayed, and then the
This is because the onload event does not require a return value, and the $ function does not return a value, so it can cause an error that has not yet been implemented.
Wrapping: The middle cannot contain a forced line break, regardless of which quotation marks are used to create the string. As follows:
Copy Code code as follows:
Will cause a parse error, you can use \ or + to wrap the line:
Copy Code code as follows:
var temp= '
<ol>\
</ol>\
';
Curly braces and semicolons are optional:
Semicolons and curly braces are not required in JavaScript, such as alert (' a '); There is no difference from alert (' a '), but there is a difference in the IF statement, and it is best not to omit it.
Overload
JavaScript is a prototype-oriented object that has no overloads such as C #, where we can call it substitution, a function with the same name regardless of the number of parameters, the program executes the last function of the same name, for example, Functions alert () {} The alert function in JavaScript will be overwritten.
Scopes and closures
can participate in my blog, "Scope chains and closures in JavaScript."