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 ...
随机推荐
- 【Hibernate】05 缓存与MySQL事务隔离
Cache 什么是缓存? 数据存储到数据库,是从内存中以流的方式写进[输出]到数据库,其效率并不是很高 - 所以在内存中暂存一部分数据,可以不以流的方式读取,效率是非常高的[相对于流来说] Hiber ...
- 【DataBase】MySQL 31 游标
游标 Cursor 游标是用来存储查询的结果集的数据类型,也称为是光标 在存储过程和函数中可以使用光标对结果集进行循环的处理 光标的使用包括1.声明,2.开启,3.关闭,4.Fetch 游标仅用于存储 ...
- 【Node】下载安装(Linux)
不要使用源码包安装!!!编译时间太长!! 不要使用源码包安装!!!编译时间太长!! 不要使用源码包安装!!!编译时间太长!! 使用Node源码包安装 这里使用的是源码包安装 Node官网地址:也不是官 ...
- window系统使用经验:新买的window11初始化时最好要选择用Microsoft账户激活,而不要用local账户激活
Windows系统初始化时有两种类型的账户可以选择,一种时Microsoft账户,一种时local账户,Microsoft账户需要联网初始化,而local账户则和传统的初始化方式一致,即账号信息保存在 ...
- 为什么要使用工业仿真软件? —— CAE(Computer Aided Engineering)工程设计中的计算机辅助工程
CAE技术: 引自: https://baike.baidu.com/item/CAE技术/18884456?fr=ge_ala 引自: https://www.mscsoftware.com.cn/ ...
- Jax框架:通过显存分析判断操作是否进行jit编译
相关: https://jax.readthedocs.io/en/latest/device_memory_profiling.html 代码: import jax import jax.nump ...
- Jax框架的jit编译是否可以使用循环结构,如果使用循环结构需要注意什么(续)
前文: Jax框架的jit编译是否可以使用循环结构,如果使用循环结构需要注意什么 从前文我们知道,jax的jit中尽可能的不要放入循环结构,因为在jit编译时会将循环结构暂开,因而会消耗掉大量的时间进 ...
- python版本的“共轭梯度法”算法代码
在看代码的过程中遇到了共轭梯度法这个概念,对这个算法的数学解释看过几遍,推导看过了,感觉懂了,然后过上一些日子就又忘记了,然后又看了一遍推导,然后过了一些日子也就又忘记了,最后想想这个算法的数学解释就 ...
- 暑假Java自学进度总结05
一.今日所学: 1.if的第一个表达式: if(关系表达式){ 语句: } 执行流程: 1>首先执行关系表达式的值 2>如果关系表达式的值为true则执行语句,否则不执行 3>继续执 ...
- 为了给Javaer落地DDD,我们不得不写开源组件
本文上回书接<这是DDD建模最难的部分(其实很简单)>,欢迎关注我的同名公众号. https://mp.weixin.qq.com/s/HZKMLF0_I10iczzp2mAR-w 故 ...