JavaScript's Process Control statements
Learning Essentials:
Expression statement meaning
SELECT statement: If, if...else, switch
Looping statements: While, Do...while, for, for...in
Jump statement: Break, continue
Exception handling Statements: Throw, try...catch...finally
One, expression statements
An expression statement is usually an assignment statement, a function or method invocation statement, and so on.
Second, select the statement
An if (conditional expression) statement; if (conditional expression) {statement;} else{statement;} And there's if...lese nesting.
Switch: You can choose which block of statements to execute against different values for the variable. If they are not the same, then the statement block after default is executed.
Third, the circular statement
While:while (conditional expression) {statement;} Is the loop statement that is run after the first judgment. Executes the loop body when the condition is met.
do...while:do {statement;} while (conditional expression); Is the loop statement that is run and then judged. Whenever the condition is met, the loop body is executed first.
For:for (;;) {statement;} First judge, then run the loop statement.
For...in: is a precise iterative statement that can be used to enumerate the properties of an object.
var myobject={ ' name': ' Zhang San ', ' age ':, ' sex ': ' Male '};for (Var p in MyObject) {document.write (P) + "<br>";}
Iv. Jump Statements
Break: Jumps out of the loop body and executes the statement behind the loop body.
Continue: Exits the current loop and executes the next loop.
V. Exception handling Statements
Throw: Throw exception
Try...catch...finally: can handle thrown exceptions
Try
< statement block 1>//throws an exception
catch (E)//catch statement catches the thrown exception and assigns a value to the variable E
< statement block 2>
Finally
< statement block 3>//Whether the statement block 1 throws an exception, the statement block 3 is executed.
Vi. Other statements
With: Sets the scope of the code to a specific object.
Document.forms[0].mytest1.value= " first text box"; with (Document.forms[0]) { mytest2.value=" second text box"; Mytest3.value= "Third text box";}
JavaScript Basic Learning (iv)