From 91bca910871ea185e7970937a9739dbbf3d223a9 Mon Sep 17 00:00:00 2001 From: alattalatta Date: Mon, 26 Jul 2021 22:51:29 +0900 Subject: Remove hidden/noinclude from JS docs (#1583) --- .../reference/global_objects/promise/index.html | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'files/ko/web/javascript/reference/global_objects/promise/index.html') diff --git a/files/ko/web/javascript/reference/global_objects/promise/index.html b/files/ko/web/javascript/reference/global_objects/promise/index.html index a06ff3cc40..cc9c9bc427 100644 --- a/files/ko/web/javascript/reference/global_objects/promise/index.html +++ b/files/ko/web/javascript/reference/global_objects/promise/index.html @@ -107,16 +107,18 @@ myFirstPromise.then((successMessage) => {

고급 예제

- -

다음의 작은 예제는 Promise의 동작 방식을 보여줍니다. testPromise() 함수는 {{HTMLElement("button")}}을 클릭할 때마다 호출되며, {{domxref("window.setTimeout()")}}을 사용해 1~3초의 무작위 간격 이후 프로미스 횟수(1부터 시작하는 숫자)로 이행하는 프로미스를 생성합니다. Promise() 생성자는 프로미스를 만드는 데 쓰입니다.

프로미스 이행은 {{jsxref("Promise.prototype.then()","p1.then()")}}을 사용하는 이행 콜백 세트를 통해 단순히 로그에 남습니다. 약간의 로그를 통해, 함수의 동기 부분이 비동기적 프로미스의 완료와 어떻게 분리되어 있는지 확인할 수 있습니다.

-
'use strict';
+

HTML

+ +
<button id="btn">프로미스 만들기!</button>
+<div id="log"></div>
+ +

JavaScript

+ +
'use strict';
 var promiseCount = 0;
 
 function testPromise() {
@@ -159,17 +161,15 @@ function testPromise() {
     log.insertAdjacentHTML('beforeend', thisPromiseCount +
         ') 프로미스 생성 (<small>동기적 코드 종료</small>)<br/>');
 }
-
- +} +

이 예제는 버튼을 클릭하면 실행됩니다. Promise를 지원하는 브라우저가 필요합니다. 짧은 시간 안에 버튼을 여러 번 클릭하여, 서로 다른 프로미스가 번갈아 이행되는 것을 볼 수도 있습니다.

-- cgit v1.2.3-54-g00ecf