关注
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
相关推荐
01-22 00:31
南京信息工程大学 Java 点赞 评论 收藏
分享
点赞 评论 收藏
分享
牛客热帖
更多
正在热议
更多
# 牛客新年AI问运 #
10988次浏览 148人参与
# 第一次面试 #
1072824次浏览 13736人参与
# 牛客AI体验站 #
17262次浏览 297人参与
# 投递几十家公司,到现在0offer,大家都一样吗 #
329228次浏览 2128人参与
# 你喜欢工作还是上学 #
89949次浏览 888人参与
# 被AI治愈的瞬间 #
91177次浏览 690人参与
# 有必要和同事成为好朋友吗? #
1892次浏览 34人参与
# 虾皮求职进展汇总 #
378427次浏览 2795人参与
# 百度求职进展汇总 #
667826次浏览 6293人参与
# 招聘要求与实际实习内容不符怎么办 #
169601次浏览 926人参与
# 如果不上班,你会去做什么 #
29524次浏览 466人参与
# 非技术岗薪资爆料 #
491550次浏览 3047人参与
# 你找工作的时候用AI吗? #
173874次浏览 893人参与
# 产品薪资爆料 #
159040次浏览 855人参与
# 你觉得什么岗位会被AI替代 #
41793次浏览 283人参与
# 考研失败就一定是坏事吗? #
222640次浏览 1543人参与
# 国企vs私企,你更想去? #
320217次浏览 2532人参与
# 我的求职精神状态 #
431991次浏览 3082人参与
# 秋招想进国企该如何准备 #
127625次浏览 620人参与
# 卷__卷不过你们,只能卷__了 #
42423次浏览 669人参与
查看20道真题和解析