1. Introduction method
<script type= "Text/javascript" > Specific code </script>
<script type= "Text/javascript" src= "Apple.js" ></script>
2. Case-sensitive
JavaScript language is strictly case-sensitive name name
3. How to Annotate
Comment Line
/*
Comment Multiple lines
*/
4. The end of the disposition number can be omitted (multiple expressions written in one line cannot be omitted)
var name= "Tom";
var age = 23;
5. Variable naming rules
Name composition: Letters, numbers, underscores, $
The first character of the start cannot be a number.
var $ = "China"; Yes, the jquery framework
var 9 = "Hello"; No
6. Global variables and local variables
① define "global variables" in JS and define them directly at any corner of the system (without using the var keyword)
② special cases, variables defined by Var outside the function are also "global"
Variables defined by var outside of nested functions in the ③ function can be used relative to this function
7. Connection Symbol +
When two parameters are numeric, do arithmetic operations; When two parameters one or two are string types, do the link operation
8. Break and Continue
Jump out of a loop and use it directly, if you need to jump out of multiple loops, use the following methods:
Waibian: For (var i=0; i<10; i++) { document.write (i+ "<br/>"); for (var j=100; j>=90; j--) { //j==95 jumps outside the loop break //if (j==95) { //break 2; Do not use the number 2 (this usage is PHP's syntax rule) //Break Waibian; } //j==95 jumps out of the "This" loop (let the outer for loop go directly to the next) if (j==95) { continue Waibian; } document.write (j+ "<br/>"); } }
9.switch
A switch condition can be a value, an expression, and a case can be followed by a constant, a variable, an expression