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) {
 console.log(i);
 i++;
}

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';
console.log(result);

Expression statements:

let x = 10;
let y = 20;
let z = x + y;
console.log(z);

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

JavaScript must be enabled for certain features to work
* Required information
1000

Comments

No comments yet. Be the first!
(追記) (追記ここまで)
(追記) (追記ここまで)

AltStyle によって変換されたページ (->オリジナル) /