From c29b722e89c4c2ed85e06db3f346992a80b4b49f Mon Sep 17 00:00:00 2001 From: Leon Xu <6479451-leonxu260@users.noreply.gitlab.com> Date: Sun, 17 Oct 2021 16:57:04 -0700 Subject: [PATCH] doc: add still asynchronous section --- source/_posts/异步JavaScript.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/source/_posts/异步JavaScript.md b/source/_posts/异步JavaScript.md index 579eabf..aa6bf05 100644 --- a/source/_posts/异步JavaScript.md +++ b/source/_posts/异步JavaScript.md @@ -212,3 +212,15 @@ function eat() { let orderPizza = new Promise(orderExecutor); orderPizza.then(eat).then(function () { console.log('Paying the bill!'); }); ``` + +# 还是异步 +```javascript +function orderExecutor(resolve, reject) { + console.log('Pizza ordered...'); + resolve("Here's your pizza!"); +} + +let orderPizza = new Promise(orderExecutor); +orderPizza.then(function (value) { console.log(value); }); +console.log("Waiting for my pizza!"); +```