JavaScript Statements

In programming, instructions executed by a computer are called statements. There is a list of JavaScript statements. JavaScript programs are executed by a web browser in HTML.

JavaScript statements are the individual instructions that make up a JavaScript program. These statements are executed line by line, from top to bottom, and perform a specific action. JavaScript statements can be simple or complex, and they can include expressions, operators, and variables. Understanding JavaScript statements is essential for writing effective and efficient code in JavaScript. In this programming language, a statement can be a single line of code or a block of code enclosed within curly braces. The most common types of statements in JavaScript include assignment statements, conditional statements, loop statements, and function statements. By using these statements, developers can create dynamic and interactive web applications.

The comments, keywords, operators, values, and expressions are included in these statements. A JavaScript program may consist of multiple JavaScript statements. In which order we placed these statements, are executed in the same order.

Semicolon (;)

To separate the JavaScript statements semicolon is used.

The multiple statements are allowed on one line when separated by a semicolon:

JavaScript White Space

We can add white spaces in our code to make it more readable because JavaScript ignores the multiple spaces.

The below-mentioned lines are equivalent:

JavaScript Line Length and Line Breaks

The lines of more than 80 characters are avoided by the programmer for good readability. So, we can break the statement after an operator when it is not fit on one line.

JavaScript Code Blocks

We can group the JavaScript statements using curly braces.  The statements are executed together written inside the curly brackets.

<!DOCTYPE html>
<html>
<body>

<button type="button" onclick="state()"> Code block checking</button>

<script>
function state() {
document.write("Welcome to ");
document.write("Tutorials Art ");
document.write("JavaScript Lectures");
}
</script>

</body>
</html>

Output:

JavaScript Statements