JavaScript 문 참조
자바스크립트 문
HTML에서 JavaScript 문은 웹 브라우저에서 "실행"하라는 "지시"입니다.
이 문은 브라우저에 "Hello Dolly"를 쓰도록 지시합니다. id="demo"인 HTML 요소 내부:
예시
document.getElementById("demo").innerHTML = "Hello Dolly.";
명령문에 대한 자습서는 JavaScript 명령문 자습서 를 참조 하십시오.
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 |