关注
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
相关推荐
点赞 评论 收藏
分享
04-08 13:48
天津大学 Java 点赞 评论 收藏
分享
牛客热帖
更多
正在热议
更多
# 面试问题记录 #
48188次浏览 717人参与
# 你遇到过哪些神仙同事 #
70621次浏览 635人参与
# 京东TGT #
42816次浏览 164人参与
# 实习生应该准时下班吗 #
200644次浏览 1310人参与
# 我的2024小目标 #
57757次浏览 386人参与
# 百度工作体验 #
204054次浏览 1903人参与
# 工作一周年分享 #
17847次浏览 109人参与
# 面试经验谈 #
32272次浏览 441人参与
# 面试吐槽bot #
10079次浏览 66人参与
# 入职第五天,你被拉进了几个工作群 #
16657次浏览 80人参与
# 假如我穿越到了妈妈的18岁 #
4717次浏览 38人参与
# 提前批过来人的忠告 #
99018次浏览 1095人参与
# 国企和大厂硬件兄弟怎么选? #
119837次浏览 1655人参与
# 追觅科技求职进展汇总 #
14504次浏览 100人参与
# 机械人,你的第一份感谢信是谁给的 #
25605次浏览 296人参与
# 请用你的专业向妈妈表白 #
9261次浏览 78人参与
# 贝壳求职进展汇总 #
19852次浏览 140人参与
# 零跑求职进展汇总 #
4389次浏览 17人参与
# 硬件人秋招的第一个offer #
69231次浏览 1085人参与
# bilibili求职进展汇总 #
57771次浏览 577人参与
# 对妈妈没说出口的话 #
22547次浏览 463人参与