在 HTML 中,JavaScript 语句是 "instructions" 到网络浏览器的 "executed"。
此语句告诉浏览器在 id="demo" 的 HTML 元素内写入 "Hello Dolly.":
有关语句的教程,请阅读我们的JavaScript 语句教程。
JavaScript 语句通常以语句标识符识别要执行的 JavaScript 操作。
语句标识符是保留字,不能用作变量名(或任何其他名称)。
下表列出了所有 JavaScript 语句标识符:
Statement | Description |
---|---|
break | Exits a switch or a loop |
class | Declares a class |
const | Declares a variable with a constant value |
continue | Breaks one iteration (in the loop) if a specified condition occurs, and continues with the next iteration in the loop |
debugger | Stops the execution of JavaScript, and calls (if available) the debugging function |
do ... while | Executes a block of statements and repeats the block while a condition is true |
for | Loops through a block of code a number of times |
for ... in | Loops through the properties of an object |
for ... of | Loops through the values of an iterable object |
function | Declares a function |
if ... else ... else if | Marks a block of statements to be executed depending on a condition |
let | Declares a variable |
return | Stops the execution of a function and returns a value from that function |
switch | Marks a block of statements to be executed depending on different cases |
throw | Throws (generates) an error |
try ... catch ... finally | Marks the block of statements to be executed when an error occurs in a try block, and implements error handling |
var | Declares a variable |
while | Marks a block of statements to be executed while a condition is true |
截取页面反馈部分,让我们更快修复内容!也可以直接跳过填写反馈内容!