7-11 leetcode 2612
请你编写一个异步函数,它接收一个正整数参数 millis ,并休眠这么多毫秒。要求此函数可以解析任何值。
ps: promise 期约函数 (异步函数)的使用 ,promise 是一个对象 new promise
/**
* @param {number} millis
*/
async function sleep(millis) {
// 返回一个异步函数 a 就是millis时间后返回的函数
return new Promise(a => setTimeout(a,millis))
} /**
* let t = Date.now()
* sleep(100).then(() => console.log(Date.now() - t)) // 100
*/
7-11 leetcode 2612的更多相关文章
- 11. leetcode 283. Move Zeroes
Given an array nums, write a function to move all 0's to the end of it while maintaining the relativ ...
- [LintCode] Divide Two Integers 两数相除
Divide two integers without using multiplication, division and mod operator. If it is overflow, retu ...
- 地区sql
/*Navicat MySQL Data Transfer Source Server : localhostSource Server Version : 50136Source Host : lo ...
- LeetCode 11. Container With Most Water (装最多水的容器)
Given n non-negative integers a1, a2, ..., an, where each represents a point at coordinate (i, ai). ...
- 2017/11/22 Leetcode 日记
2017/11/22 Leetcode 日记 136. Single Number Given an array of integers, every element appears twice ex ...
- 2017/11/21 Leetcode 日记
2017/11/21 Leetcode 日记 496. Next Greater Element I You are given two arrays (without duplicates) num ...
- 2017/11/13 Leetcode 日记
2017/11/13 Leetcode 日记 463. Island Perimeter You are given a map in form of a two-dimensional intege ...
- 2017/11/20 Leetcode 日记
2017/11/14 Leetcode 日记 442. Find All Duplicates in an Array Given an array of integers, 1 ≤ a[i] ≤ n ...
- 2017/11/9 Leetcode 日记
2017/11/9 Leetcode 日记 566. Reshape the Matrix In MATLAB, there is a very useful function called 'res ...
- 2017/11/7 Leetcode 日记
2017/11/7 Leetcode 日记 669. Trim a Binary Search Tree Given a binary search tree and the lowest and h ...
随机推荐
- 【Java】使用Druid连接池的监控面板排查慢SQL
默认在后台服务的地址: http://localhost:8078/druid/login.html 账号信息放在配置文件中获取: server: port: 8078 spring: datasou ...
- 【Tutorial C】08 函数 Function
函数的定义 C源程序是由函数组成的. 最简单的程序有一个主函数 main(),但实用程序往往由多个函数组成, 由主函数调用其他函数,其他函数也可以互相调用. 函数是C源程序的基本模块,程序的许多功能是 ...
- 【Vue】Re04 指令:第二部分
一.v-on指令 作用是用来将元素绑定事件监听器,触发特定的函数执行一定功能 关键字:事件监听 <!DOCTYPE html> <html lang="en"&g ...
- 【转载】 Linux Hang Task 简介
原文地址: https://gohalo.me/post/linux-kernel-hang-task-panic-introduce.html --------------------------- ...
- 为什么我们需要不断的开发不同的机器学习模型 —— Do we Need Hundreds of Classifiers to Solve Real World Classification Problems?
引用: 作者:xyzh https://www.zhihu.com/question/26726794/answer/151282052 写给懒得看的人: 没有最好的分类器,只有最合适的分类器. 随机 ...
- 中美在AI领域差距12个月
看到一个新闻: <马斯克再谈AI:中美差距12个月> 其实想想这个评价也还中肯,尽管这些年国内AI大有弯道超车之势,但是不可否认的是由于欧美的历史领先优势和强大的科研及商业上的独立创新能力 ...
- DataOps真能“降本增效”?
在各行各业中,越来越多的公司开始重视收集数据,并寻找创新方法来获得真实可行的商业成果,并且愿意投入大量时间和金钱来实现这一目标. 据IDC称,数据和分析软件及云服务市场规模在 2021 年达到了 90 ...
- Java数组小白版
一.数组概念 一.数组定义 数组就是指在计算机内存中开辟的连续存储空间,用于存放程序运行中需要用到的一组相同类型数据的容器. 二.数组的声明 +数组的长度 定义数组时需要确定数组的长度(元素的个数), ...
- Java学习笔记1--JDK,JRE和JVM
1.Java开发环境 Java开发环境是指Java程序员开发.编写.测试和调试Java程序所使用的所有工具和技术.Java开发环境通常由以下几个部分组成: JDK(Java Development K ...
- QT基础-弹出框(信息框,模态框,操作框)
学习前端知识的时候就了解到让用户使用的界面一定要足够清晰,因为你永远不知道用户会以何种方式打开你开发的软件,所以莫泰提示框就很重要了.下面将会介绍几本的集中模态对话框,用来提升用户体验! 1.模态框 ...