2022-03-08 Learning record--The difference between JS-if and while

ifdifference whilebetween

[ ifIt is a judgment statement, whilea loop statement]

1. ifJudgment statement

if(判断条件) {
	执行代码。。。
}

✍ If the condition is met, the code is executed; if not, the code cannot be executed.

2. whileLoop statement

whileThe loop statement is divided into whilesum do-while, the following is whilean example

while(循环条件) {
	执行代码。。。
}

✍If the condition is met, execute the code; then judge whether the condition is met, if it is met, execute the code in a loop until the condition is not met, execute whilethe code after the statement

【Supplement】The difference between whileanddo-while

insert image description here

Guess you like

Origin blog.csdn.net/weixin_48850734/article/details/123347303