JavaScript Basic Learning (iv)

Source: Internet
Author: User
Tags throw exception

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)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.