async function declaration expects ';' in Internet Explorer

守給你的承諾、 提交于 2021-02-08 03:01:46

问题


I have an async function declaration that works on Chrome and Firefox, but gives the following error in internet explorer.

SCRIPT1004: Expected ';'

File: javascriptFile.js, Line: 5, Column 7

This is the simplified version with these two function at the top of the file, and it still fails on internet explorer.

function sleep (ms) {
  return new Promise(function (resolve) { setTimeout(resolve, ms) })
}

async function begging (help) {
  await sleep(1000)
  console.log('please')
}

I can not seem to find anything about not being able to declare async functions in internet explorer. I would really appreciate any help at all, I'm not sure where to look next in order to figure this out.


回答1:


Internet Explorer does not support async functions, and never natively will. The main drawback of using new JavaScript features is lack of support.



来源:https://stackoverflow.com/questions/45681318/async-function-declaration-expects-in-internet-explorer

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!