JS Statement

JS Statement

JS Statement

 

In JavaScript, a statement is a piece of code that performs a specific action, such as assigning a value to a variable, looping through a set of instructions, or calling a function.

A statement in JavaScript is typically terminated with a semicolon (;) to indicate the end of the statement. However, JavaScript also allows you to omit the semicolon in some cases, as it can automatically insert semicolons to separate statements. This is called automatic semicolon insertion.

Here are a few examples of JavaScript statements:

Assigning a value to a variable:

				
					let x = 5; 
				
			

Calling a function:

				
					alert("Hello, world!"); 
				
			

Looping through a set of instructions:

				
					for (let i = 0; i < 10; i++)
{

console.log(i);

}
				
			

As you can see, statements in JavaScript can take different forms and can be used for a wide range of purposes.

Join To Get Our Newsletter
Spread the love