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 ...
随机推荐
- Jmeter函数助手8-counter
counter函数用于线程计数,类似计数器. TRUE每个用户有自己的计数器:FALSE使用全局计数器:即线程之间是否需要共享累加计数器,TRUE否,FALSE是 存储结果的变量名(可选) 1.线程之 ...
- 【Mybatis-Plus】制作逆向工具
官方文档可参考: https://baomidou.com/pages/779a6e/#快速入门 工具需要的依赖 <?xml version="1.0"?> <p ...
- 【Java】数组强转问题
问题产生 问题代码: List<String> strs = new LinkedList<String>(); // 中间有添加元素的操作,这里省略... // 这里toAr ...
- 使用浪潮AI计算平台之分布式计算(Tensorflow框架下 PS/Worker模式下的异步计算)
虽然Tensorflow一直都是支持分布式计算的,但是由于只有一台电脑,一个GPU,所以别说分布式的tensorflow的使用了,就是单机多卡都是没有使用过的,由于后来可以有机会使用这个浪潮的AI计算 ...
- 记录一次实验室显卡服务器崩溃事件(Ubuntu18.04 server系统,4块NVIDIA的特斯拉显卡)
系统报错(显示屏上的错误): 系统中的日志文件中所有的log文件都没有记录这次崩溃事件. 不过根据屏幕上显示出的报错,大致估计为显卡的问题: 重启后查看显卡地址: 发现报错的显卡是 0号显卡.个人估 ...
- 纯css美化滚动条样式
https://www.emperinter.info/2020/09/20/scrollbar-in-browser/ 自己完善自己博客再Ipad等移动端的菜单时选用了左右滑动的菜单模式!当然就会使 ...
- java-多线程(下)
多线程简单入门(Java)(下篇:多线程Java中的使用) 目录 一.创建多线程 二.线程的安全 三.线程的通信 一.创建多线程 在Java中,多线程的创建有4种方式. 方式一:继承于Thread类; ...
- 推荐一款Python开源移动应用安全测试分析工具!!!
今天给大家推荐一个安全测试相关的开源项目:nccgroup/house 1.介绍 它是一个由 NCC Group 开发的,一个基于Frida和Python编写的动态运行时移动应用分析工具包,提供了基于 ...
- 从0实现基于Linux socket聊天室-多线程服务器一个很隐晦的错误-2
根据 <0 基于socket和pthread实现多线程服务器模型>所述,server创建子线程的时候用的是以下代码: pconnsocke = (int *) malloc(sizeof( ...
- 卷积神经网络CNN实战:MINST手写数字识别——网络定义
本文基于python-pytorch框架,编写CNN网络,并采用CNN手写数字数据集训练.测试网络. 网络的构建 以LeNet-5 网络为例 类定义 首先先了解一下网络的最基本框架 一般而言,首先创建 ...