LoginSignup
0
0

JS

Last updated at Posted at 2024-02-13
function initialize() {
  return new Promise((resolve, reject) => {
    console.log("1:ここに先に終わらせたい処理を書く");
    resolve();
  });
}

function movePic() {
  console.log("2:1の完了後に実行したい処理");
}

(async () => {
  await initialize();
  movePic();
})();
function initialize() {
  return new Promise((resolve, reject) => {
    setTimeout(() => {
      console.log("1:初期処理");
      resolve();
    }, 5000);
  });
} 

(async () => {
  await initialize();
  (() => {
  	console.log("2:1が終わってから実行させたい処理。");
  })();
})();

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0