Home >Web Front-end >JS Tutorial >Detailed analysis in JavaScript_javascript skills

Detailed analysis in JavaScript_javascript skills

WBOY
WBOYOriginal
2016-05-16 17:52:13982browse

JavaScript is case-sensitive: Variables and functions in JavaScript are case-sensitive, for example:

Copy code The code is as follows:

function myfunction(){} is different from
function myFunction(){}

The core objects Array, Object, etc. in JavaScript are also case-sensitive.

Single quotation marks and double quotation marks: This problem arises when I am learning SQLServer to splice the string "select * from page where name='lida'": Are the three ''s at the end the double quotation marks first or the single quotation marks? Quotation marks first? If you have learned a lot, you will know that double quotes are used by programming languages, and single quotes are used by SQL server to indicate the string type. However, there is no special difference between single quotes and double quotes in JavaScript. Both can be used to create strings. However, in general, JavaScript uses single quotes, and attribute values ​​such as HTML must use double quotes. At the same time, single quotes can include double quotes. You can also include single quotes; in special cases, you need to use the escape symbol "", for example:
Copy code The code is as follows:

var temp='

What's this?';


The function of brackets: Like other languages, the brackets in JavaScript are also There are two functions, one is used as a separator, for example: (1 1)*2; the second function is an expression, for example: (1 1)*2; the second function is an expression, for example: ( The separated brackets in function (){})() are delimiters, and the following brackets represent the execution method.

Function calls and references:
Copy code The code is as follows:

var temp=myFunction();
var temp=myFunction;

Because brackets can represent execution, the first temp represents the return value of the myFunction function, and the second temp represents It is to assign myFunction to temp. For example:
Copy code The code is as follows:



The webpage can be loaded normally, because this means that the $ method is assigned to window.onload, and the page loading runs the $() function written by yourself; if you replace this sentence with
window .onload=LD.$(); The running result is as follows; first it will display "Buffering", then
Detailed analysis in JavaScript_javascript skills
This is because the onload event does not need to return a value, and the $ function does not return a value either. So it will lead to errors that have not yet been implemented.
Newline: No matter what kind of quotation marks are used to create the string, it cannot contain a forced newline character in the middle. As follows:
Copy code The code is as follows:

var temp='

List



'

will cause a parsing error, you can use or to break the line:
Copy code The code is as follows:

var temp='

List


';


Braces and semicolons are optional:
Semicolons and braces in JavaScript It is not necessary. For example, there is no difference between alert('A'); and alert('A'), but there is a difference in the operation of the if statement. It is best not to omit it.
Overloading
JavaScript is object-oriented based on prototypes. There is no overloading like in C#. Here we can call it replacement. Regardless of whether the number of parameters of the function with the same name is the same, the program will execute the last function with the same name. For example, function alert(){} will override the alert function in JavaScript.
Scope and Closure
You can join my blog "Scope Chain and Closure in JavaScript".
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn