do...while
Baseline
Widely available
This feature is well established and works across many devices and browser versions. Itâs been available across browsers since 2015ë 7ì.
do...while 문ì í
ì¤í¸ ì¡°ê±´ì´ ê±°ì§ì¼ë¡ íê°ë ëê¹ì§ ì§ì ë 구문ì ì¤ííë 루í를 ë§ëëë¤.
ë¨, êµ¬ë¬¸ì´ ì¤íë ë¤ì í
ì¤í¸ ì¡°ê±´ì´ íê°ë¨ì¼ë¡ 구문ì 무조건 í ë²ì ì¤íë©ëë¤.
ìëí´ ë³´ê¸°
let result = "";
let i = 0;
do {
i = i + 1;
result = result + i;
} while (i < 5);
console.log(result);
// Expected output: "12345"
문ë²
do {
statement;
} while (condition);
구문-
í ì¤í¸ ì¡°ê±´ì´ ì°¸ì¼ ëë§ë¤ í ë²ì´ì ì¤íëë 구문ì ëë¤. ë§ì½ 루í ë´ìì ì¬ë¬ 구문ì ë°ë³µ ì¤í ìí¤ê³ ì¶ì¼ìë¤ë©´, ë¤ì ëª ë ¹ì ì¬ì©í©ëë¤. block 구문ì íì©íì¬ (
{ ... }) ì´ë° ìì¼ë¡ 그룹íí©ëë¤. ì¡°ê±´ì-
루íê° ì¤íë ëë§ë¤ íê°ëë ìì ëë¤. ë§ì½ ì¡°ê±´ìì´ ì°¸ì¼ë¡ íê°ëìë¤ë©´,
êµ¬ë¬¸ì´ ë¤ì ì¤íë©ëë¤. ë§ì½ ì¡°ê±´ìì´ ê±°ì§ì¼ë¡ íê°ëìë¤ë©´, JavaScriptëdo...while. 구문 ë°ì ìë 구문ë¤ì ì¤íìíµëë¤.
ìì
>do...while
ìì ìì do...while 문ì ì ì´ë íë² ë°ë³µëê³ i ë³ìê° 5 ë³´ë¤ ìì ëê¹ì§ ì¤íë©ëë¤.
var result = "";
var i = 0;
do {
i += 1;
result += i + " ";
} while (i > 0 && i < 5);
// Despite i == 0 this will still loop as it starts off without the test
console.log(result);
ëª ì¸ì
| Specification |
|---|
| ECMAScript® 2027 Language Specification> # sec-do-while-statement> |