본문 바로가기

개발이야기/Javascript

IE에서 ES6 + Promise 사용하기

<script src="https://cdnjs.cloudflare.com/ajax/libs/babel-core/5.8.34/browser.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/babel-polyfill/6.26.0/polyfill.min.js"></script>
<script type="text/babel">

  const a = () => {
    console.log(`hello world!`);
  };

  a();

  const wait = (ms) => {
    return new Promise((r) => setTimeout(r, ms));
  };

  const hello = async () => {

    await wait(1000);

    console.log("world1");

    await wait(1000);

    console.log("world2");

    await wait(1000);

    console.log("world3");

  };

  hello();

</script>

테스트 브라우저 : IE11, 크롬, 엣지, 웨일 모두 잘됨 확인

 

다른 cdn을 사용했을시 IE11에서 오류가 발생 하였는데 위의 cdn 사용시 오류 없이 잘됨