[JavaScript] JavaScript learning 4 JavaScript statements

Source: Internet
Author: User

Javascript is a sequence of statements executed by the browser.

Javascript statements

The javascript statement is a command sent to the browser. These commands are used to tell the browser what to do.

This JavaScript statement tells the browser to output "Hello World" to the webpage ":

 
Document. Write ("Hello World ");

A semicolon is usually added at the end of each line of statements. Most people think this is a good programming habit, and this is often seen in Javascript cases on the web.

The semicolon is optional (based on JavaScript standards). The browser uses the end of the line as the end of the statement. For this reason, we often see examples with no semicolons at the end.

Note:You can use semicolons to write multiple statements in a row.

JavascriptCode

JavaScript code is a sequence of JavaScript statements.

The Browser executes each statement in order of writing.

In this example, a title and two paragraphs are output to the webpage:

 
<SCRIPT type = "text/JavaScript"> document. write ("

Tiy

JavaScript code block

Javascript can be combined in batches.

The code block starts with the left curly braces and ends with the right curly braces.

The function of a code block is to execute the statement sequence together.

In this example, a title and two paragraphs are output to the webpage:

<SCRIPT type = "text/JavaScript"> {document. write ("

Tiy

The previous example is of little use. It only demonstrates the use of code blocks. A code block is usually used to combine several statements in a function or Condition Statement (for example, if the condition is met, You can execute this statement to group it ).

You will learn more about functions and conditions in a later chapter.

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.