async await 語法

 

一個基本的 await async 語法用法如下

<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width">
</head>

<body>
    <script>
        let fun1 = async (content) => {
            console.log(content);
        }

        let callfun = async () => {
            await fun1("Hello");
        }

        callfun();
    </script>
</body>

</html>

 

參考資料:

[Javascript] ES7 Async Await 聖經