关注
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
相关推荐
点赞 评论 收藏
分享
牛客热帖
更多
正在热议
更多
# Agent面试会问什么? #
30793次浏览 1222人参与
# 通信/硬件的薪资开多少,才值得去? #
76237次浏览 406人参与
# 厦门银行科技岗值不值得投 #
18585次浏览 420人参与
# 面试体验最好和最差的公司 #
22389次浏览 159人参与
# 美团笔试 #
889246次浏览 5592人参与
# 我的求职进度条 #
979240次浏览 6512人参与
# 哪些公司一直卡在简历筛选 #
103281次浏览 339人参与
# 拿到offer之后,可以做些什么 #
103294次浏览 505人参与
# 说说你知道的学历厂 #
399164次浏览 1420人参与
# 平台or薪资 硬件uu更看重哪个 #
167059次浏览 624人参与
# bilibili求职进展汇总 #
190581次浏览 1091人参与
# 听劝,这个公司值得去吗 #
714776次浏览 2024人参与
# 一人分享一个skill #
8101次浏览 218人参与
# 春招至今,你收到几个面试了? #
79235次浏览 1045人参与
# 给工作过的公司写一条大众点评,你会怎么写? #
10813次浏览 131人参与
# 美团秋招笔试 #
207966次浏览 1166人参与
# 拼多多工作体验 #
55138次浏览 387人参与
# 一人说一个提前实习的好处 #
122953次浏览 715人参与
# 烂工作和没工作哪个更痛苦? #
17935次浏览 271人参与
# 巨人网络求职进展汇总 #
193647次浏览 1232人参与
# AI替代不了什么? #
12082次浏览 201人参与
查看8道真题和解析