Get the App
SLTechnology News&Howtos  ›  Development  › 

Example Analysis of JavaScript statement, JavaScript Code and Code Block

Shulou Source: shulou.com Published: 2022-06-01 13:13:41 11月16日 Update

This article will explain in detail the sample analysis of JavaScript statements, JavaScript code and code blocks. The editor thinks it is very practical, so I share it with you for reference. I hope you can get something after reading this article.

JavaScript statement

The command issued to the browser by the JavaScript statement. Statement is used to tell the browser what to do.

The following JavaScript statement outputs the text "Hello World" to the HTML element of id= "demo":

Document.getElementById ("demo") [xss_clean] = "Hello World"

semicolon

Semicolons are used to separate JavaScript statements. Usually we add a semicolon at the end of each executable statement.

Another use of semicolons is to write multiple statements in one line.

You may also see cases without semicolons. In JavaScript, it is optional to end statements with semicolons.

JavaScript code

The JavaScript code (or only JavaScript) is a sequence of JavaScript statements.

The browser executes each statement in the order in which it is written. The following example manipulates two HTML elements:

My Web PageA Paragraph.

A DIV. Document.getElementById ("demo") [xss_clean] = "Hello World"; document.getElementById ("myDIV") [xss_clean] = "How are you?"

JavaScript code block

JavaScript statements are combined in the form of code blocks. The block starts with the left curly bracket and ends with the right curly bracket.

The purpose of the block is to make the sequence of statements execute together. The JavaScript function is a typical example of combining statements into blocks.

The following example runs a function that manipulates two HTML elements:

My Web PageI am a paragraph.

I am a div.

Tags: Statements codes semicolons facets elements browsers two functions spaces articles scripts examples analysis differences functions examples uppercase lowercase sequences Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Tech Info Xiaomi MySQL NVidia Linux