<script type="text/javascript">
function Pro(val) {
return new Promise((resolve, reject) => {
setTimeout(function() {
resolve(val)
}, 1000)
})
}
async function log(arrs) {
for(const item of arrs) {
var response = await Pro(item);
console.log(response);
}
}
log([10, 20, 30])
</script>
复制代码
面试题继发执行 : 1s后执行10,等1s后输出20,再等1s后输出30
最新推荐文章于 2021-02-25 13:40:28 发布