JavaScript statement identifier, variable period

Source: Internet
Author: User

Statement Description
Break Used to jump out of a loop.
Catch Statement block that executes a catch statement block when a try statement block performs an error.
Continue Skips an iteration in the loop.
Do ... while Executes a block of statements that continues executing the statement block when the condition statement is true.
For When the conditional statement is true, the code block can be executed a specified number of times.
For ... in Used to iterate over an array or an object's properties (to iterate over a group or an object's properties).
function Define a function
If ... else Used to perform different actions based on different conditions.
Return Exit function
Switch Used to perform different actions based on different conditions.
Throw Throws (generates) an error.
Try Implements error handling and is used with catch.
Var Declares a variable.
While When the conditional statement is true, the statement block is executed.
The lifetime of a JavaScript variable

The lifetime of JavaScript variables begins at the time they are declared.

Local variables are deleted after the function is run.

Global variables are deleted after the page is closed.

Common HTML Events
Events Description
OnChange HTML element Changes
OnClick User clicks on HTML element
onmouseover The user moves the mouse over an HTML element
onmouseout The user moves the mouse away from an HTML element
OnKeyDown The user presses the keyboard key
OnLoad The browser has finished loading the page
JavaScript tags

As you saw in the switch statement chapter, you can tag JavaScript statements.

To mark a JavaScript statement, precede the statement with a colon:

label: statements

The break and continue statements are just statements that can jump out of a block of code.

Grammar:

break labelname; continue labelname;

Continue statements (with or without label references) can only be used in loops.

The break statement (without a label reference) can only be used in loops or switch.

With a label reference, the break statement can be used to jump out of any JAVASCRIPT code block:

Instance
cars=["BMW", "Volvo", "Saab", "Ford"];list: {document.write (cars[0] + "<BR>"); document.write (Cars[1] + "<BR>"); document.write (cars[2] + "<BR>");    Break list; document.write (Cars[3] + "<BR>"); document.write (Cars[4] + "<BR>"); document.write (Cars[5] + "<BR>"); }

JavaScript Data types

There are 5 different types of data in JavaScript:

    • String
    • Number
    • Boolean
    • Object
    • function

3 Types of objects:

    • Object
    • Date
    • Array

2 data types that do not contain any values:

    • Null
    • Undefinedconstructor Property

      The constructor property returns the constructor for all JavaScript variables.

      Convert a string to a number

      The global Method number () converts the string to numbers.

      strings that contain numbers (such as "3.14") are converted to numbers (such as 3.14).

      The empty string is converted to 0.

      The other strings are converted to NaN (not a number).

      Method Description
      Parsefloat () Parses a string and returns a floating-point number.
      parseint () Parses a string and returns an integer.

JavaScript statement identifier, variable period

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.