关注
function hardMan(str) {
this.queue = []
this.name = str
this.queue.push(() => {
console.log(this.name);
this.next()
});
}
hardMan.prototype.rest = function (wait) {
const func = () => {
setTimeout(() => {
console.log(`Start learning after ${wait} seconds`)
this.next()
}, wait * 1000)
}
this.queue.push(func)
return this
}
hardMan.prototype.restFirst = function (wait) {
const func = () => {
setTimeout(() => {
console.log(`Start learning after ${wait} seconds`)
this.next()
}, wait * 1000)
}
this.queue.unshift(func)
return this
}
hardMan.prototype.learn = function (str) {
const func = () => {
console.log(`Learning ${str}`)
}
this.queue.push(func)
this.next()
}
hardMan.prototype.next = function () {
if (this.queue.length === 0) return
const func = this.queue.shift()
func()
}
const HardMan = (name)=>{
return new hardMan("jack");
}
查看原帖
4 1
相关推荐
点赞 评论 收藏
分享
牛客热帖
更多
正在热议
更多
# 考研对你找工作产生了哪些影响? #
2080次浏览 32人参与
# 机械只有读研才有出路吗? #
19659次浏览 228人参与
# 聊聊这家公司值得去吗 #
236079次浏览 2197人参与
# 远程面试的尴尬瞬间 #
100684次浏览 827人参与
# 你认为哪个岗位找工作最卷 #
15115次浏览 55人参与
# kpi面有什么特征 #
34257次浏览 245人参与
# 工作中哪个瞬间让你想离职 #
24072次浏览 166人参与
# 职场人,说说你的烦心事 #
8801次浏览 81人参与
# 职场上哪些事情令人讨厌 #
16794次浏览 86人参与
# 为了找工作你投递了多少公司? #
10866次浏览 148人参与
# 你有哪些缓解焦虑的方法? #
2341次浏览 111人参与
# 你今年的平均薪资是多少? #
126587次浏览 661人参与
# 秋招最大的收获是什么? #
34049次浏览 300人参与
# 运营/市场营销人的秋招现状 #
17143次浏览 189人参与
# 硬件人绝对不能踩的坑 #
61126次浏览 734人参与
# 大家每天通勤多久? #
42055次浏览 331人参与
# 实习生应该准时下班吗 #
223374次浏览 1397人参与
# 如果可以,你希望哪个公司来捞你 #
88193次浏览 371人参与
# 运营人求职交流聚集地 #
135259次浏览 983人参与
# 入职第一天,你准备什么时候下班 #
56619次浏览 357人参与