Javascript
It was first created by Netscape (Mozilla) and renamed ecmascript
Microsoft JScript
Sun (now Oracle) registered Javascript
Some browsers use F12 to wake up/Close the firebug Operation Panel, CTRL + Shift + J to wake up the error Console (error console)
On the Javascript console, you can enter JS Code and run the result.
Console. Log () function
Most browsers implement simple console APIs, which can be output to the console using console. Log () (either IE or Firefox), or alert ()
Window. onload
The load event starts to execute JavaScript code only after the file is loaded.
Window. onload = function (){}
Assign the function body to the function name.
<SCRIPT type = "text/JavaScript">
Window. onload = function (){
Alert (1 );
VaR square = function (x ){
Return x * X;
}
Alert (square (5 ));
Console. Log (square (66 ))
};
</SCRIPT>
As shown above, you can use VaR fuctionname = function () {...} to assign the function content to the function name.
When using this function, you can call it by using the function name behind var.
The this keyword in the method is a reference to the object that defines (CALLS) the method.
Confirm Function
Function moveon (){
VaR answer = confirm ("do you want to open the page? ");
Console. Log (answer );
If (answer ){
Window. Location = "http://www.baidu.com ";
}
}
Javascript is case sensitive and the Function Specification is in lowercase.
HTML is case insensitive, and XHTML is case sensitive. The tag name and function name can be in upper case in HTML, but in JS, they must be in lower case.
For example, you can write onclick in HTML, but use lower-case onclick in Js.
Unicode Escape Character Sequence
JS defines a special sequence that uses six ASCII characters (prefixed with \ U, followed by four hexadecimal numbers) to represent any 16-bit Unicode Internal code. For example, \ u00e9.
It can appear in strings, regular expressions, and identifiers. escape characters can represent the characters before the escape, and the effect is the same.
Note:
// Single line comment
/**/Multi-line comment
Literal-directly use data values in the program
It can be numbers, decimals, strings, true, false, or null.
Number of arrays directly [1, 2, 3]
Object direct quantity {X: 1, Y: 2}
Identifier
It must start with a letter, underscore, or dollar sign, followed by a letter, underscore, dollar sign, or number.
Although letters and numbers in the full set of Unicode are allowed, we usually only use ASCII letters and numbers.
Keywords are not allowed to be reserved. Avoid using predefined global variables and function names in JavaScript to define variable names and function names.