<html><body><h1>JavaScript Promise 对象</h1><h2>Promise.all() 方法</h2><p id="demo"></p><script>// 创建一个 Promiseconst myPromise1 = new Promise((resolve, reject) => { setTimeout(resolve, 200, "国王");});// 创建另一个 Promiseconst myPromise2 = new Promise((resolve, reject) => { setTimeout(resolve, 100, "王后");});// 两个 Promise 都完成。谁更快?Promise.all([myPromise1, myPromise2]).then((x) => { myDisplay(x);});// 当 Promise 完成时运行的函数:function myDisplay(some) { document.getElementById("demo").innerHTML = some;}</script></body></html>