function HardMan(str) { this.queue = [] this.name = str console.log(this.name) } HardMan.prototype.rest = function(wait) { const that = this const func = () => { setTimeout(() => { console.log(`Start learning after ${wait} seconds`) // debugger; that.next() }, wait * 1000) } this.queue.unshift(func) return this } HardMan.prototype.restFirst = function(wait) { const that = this const func = () => { setTimeout(() => { console.log(`Start learning after ${wait} seconds`) that.next() }, wait * 1000) } this.queue.unshift(func) return this } HardMan.prototype.learn = function(str) { const func = () => { console.log(str) } this.queue.push(func) this.next() } HardMan.prototype.next = function() { if(this.queue.length === 0) return const func = this.queue.shift() func() } 我感觉只能new 出来以后再用,直接用函数我也不会。。
2 3

相关推荐

05-29 22:11
门头沟学院 Java
Elastic90:抛开学历造假不谈,这公司的招聘需求也挺怪的,Java开发还要求你有图文识别、移动端开发和c++的经验,有点逆天了。
点赞 评论 收藏
分享
见见123:简历没有啥问题,是这个社会有问题。因为你刚毕业,没有工作经历,现在企业都不要没有工作经历的。社会病了。
点赞 评论 收藏
分享
牛客网
牛客网在线编程
牛客网题解
牛客企业服务