wangbinze / Daily---3and1

0 stars 0 forks source link

❤️❤️❤️Question009-JavaScript、JS中常用的语句有哪些? #9

Open wangbinze opened 3 years ago

wangbinze commented 3 years ago

题目:JS中常用的语句有哪些?

wangbinze commented 3 years ago

语句通常使用一或多个关键字完成既定的任务。也称流控制语句

if

do-while

let i = 0; 
do { 
 i += 2; 
} while (i < 10);

while

let i = 0; 
while (i < 10) { 
 i += 2; 
}

for

let count = 10; 
for (let i = 0; i < count; i++) { 
 console.log(i); 
}

fon-in

for (const propName in window) { 
 document.write(propName); 
}

for-of

for (const el of [2,4,6,8]) { 
 document.write(el); 
}

标签

start: for (let i = 0; i < count; i++) {  //start 就是一个标签
 console.log(i); 
}

break和continue

with

switch

switch (expression) {
    case value1:
        statement;
        break;
    case value2:
        statement;
        break;
    default:
        statement;
}