Besides attention to capitalization, what's the other wood?
Switch Statement
Switch (variable) {
Case 1:
if the variable and the value of 1 are the same, execute the code at that point
Break
Case 2:
if the variable and the value of 2 are the same, execute the code at that point
Break
Case 3:
if the variable and the value of 3 are the same, execute the code at that point
Break
Default
If the variable and the above values are not the same, execute the code here
Break
}
The data type of the variable behind the switch and the value behind the case must be consistent.
A Switch statement can make a collective judgment on a variable:
self-increment self-reduction
i++ ++i
In the case of not participating in the operation,i++ and ++i are all on the basis of the variable plus 1
In the case of participating in the operation
Var i=123;
Var j=i++; the first I the value 123 assign a value to J, and then the self-increment
The value of J is 123 I value is 124
Var J=++i; I increment first, in assignment to J
The value of J is 124, andthe value ofI is 124
While Loop
while (conditional expression) {
The loop executes as long as the conditional expression evaluates to True, and the loop terminates when the conditional expression evaluates to False
}
The while Loop statement needs to define variables in the loop body now
Do While
do{
loop body Code; First execute the Loop body code once. If the expression at the back of the while evaluates to true, the loop experiences a loop. If the result is false, the loop terminates.
}while (conditional expression)
Do While loops more than one time loop
for Loop
for (define variable; conditional expression; self-increment) {
Loop Body Code
}
Execution Order :
Define variables First
if the conditional expression evaluates to true, the code in the For loop is executed , and if false, the Loop body code terminates execution.
Performs a variable and conditional expression loop once, then performs the self-increment decrement
Break Statement
in the loop, the program immediately ends the current loop as long as the code encounters a break.
The current loop refers to the body of the loop where the break statement is located.
continue Statements
The Continue statement refers to jumping out of the loop, where the code behind the statement is no longer executed and the entire loop body continues to loop.
Array
Defined
Assign Value
The array is assigned by means of subscripts. The subscript starts from 0 .
initialization and traversal of arrays
The number of array data length property
Gets the array length (number of elements) by the array name . length
Array Merging
use the concat method to combine arrays.
The Join method returns a string
function
function (method) definition
by using the function keyword
and custom method names You can define a function. as follows:
Method is called:
Function Case Description:
javascript.03--arrays, simple logic, custom functions