Programming Tutorials

Statements in JavaScript

By: aathishankaran in JavaScript Tutorials on 2007-03-21  

In JavaScript, a statement is a unit of code that performs a specific action. It is used to create a program or to perform a specific task. There are different types of statements in JavaScript, such as control statements, loop statements, conditional statements, etc. Here are some examples of statements in JavaScript:

Control statements:

let age = 25;

if(age > 18) {
  console.log('You are an adult');
} else {
  console.log('You are not an adult');

Loop statements:

let i = 1;
while(i <= 5) {

Conditional statements:

let a = 5;
let b = 10;

let result = (a > b) ? 'a is greater than b' : 'a is less than or equal to b';

Expression statements:

let x = 10;
let y = 20;
let z = x + y;

Jump statements:

for(let i = 1; i <= 10; i++) { if(i === 5) { continue; } console.log(i); }

In the above examples, we can see different types of statements that perform different actions such as conditional, looping, etc.

Add Comment

* Required information


No comments yet. Be the first!

Most Viewed Articles (in JavaScript )

Latest Articles (in JavaScript)