Home > Web Front-end > JS Tutorial > Javascript basic tutorial if conditional statement_basic knowledge

Javascript basic tutorial if conditional statement_basic knowledge

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-05-16 16:19:35
Original
1482 people have browsed it

if is one of the commonly used syntaxes, its format is as follows

if(coditon) statement1 (else statement2)

Among them, coditon can be any expression, even a real Boolean value, because JavaScript will automatically convert it into a Boolean value.

If the condition execution result is true, statement1 will be executed. If the condition is false, the execution result statment2 will be executed. (If statement2 exists, else is not necessary.)

Each conditional statement can be a single line of code or a block of code. The following is a simple example

Copy code The code is as follows:

var iNumber = Number(prompt("Please enter a number between 5 and 100"));
If (isNaN(iNumber))
Document.write("Please confirm the number you entered.");
else if(iNumber > 100 || iNumber < 5 )
Document.write("The value you entered is not within the range");
else
Document.write("The value you entered is " iNumber);
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Issues
What are JavaScript hook functions?
From 1970-01-01 08:00:00
0
0
0
What is JavaScript garbage collection?
From 1970-01-01 08:00:00
0
0
0
c++ calls javascript
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template