三七互娱秋招,前端笔试编程题(一)讨论


var Hero = function(name){
    if(this.constructor.name !== 'Hero') {
        return new Hero(name)
    }
    this.name = name;
    (function(){
        console.log(`Hi this is ${name}`)
    })()
    return Promise.resolve(this)
}

Promise.prototype.kill = function(num){
    return this.then(()=>{
        if(num & 1 !== 0){
            console.log(`kill ${num} 注意这里是单数`)
            return this
        }
        console.log(`kill ${num} 注意这里是复数`)
        return this
    })
}

Promise.prototype.recover = function(num){
    return this.then(()=>{
        console.log(`Recover ${num} bloods`)
        return this
    })
}

Promise.prototype.sleep = function(num){
    return this.then(() => new Promise(resolve=>{
        var timer = setTimeout(()=>{
            clearTimeout(timer)
            console.log(`sleep ${num} 秒`)
            resolve(this)
        },num * 1000 )
    }))
}

#三七互娱##前端##秋招#
全部评论
渣渣表示看不太懂呀
点赞 回复 分享
发布于 2018-09-20 21:23
前端兄弟一枚
点赞 回复 分享
发布于 2018-09-07 08:57

相关推荐

02-26 09:15
已编辑
蚌埠学院 golang
点赞 评论 收藏
分享
01-30 22:03
门头沟学院 Java
用微笑面对困难:我滴妈,【俩月】【实习】【主管】仨debuff吃满了,独立设计开发的项目写了绝大占比的运营板块,你独立开发,那维护、问题复盘、日志更新、bug、策划书全是自己整的? 不建议写那么大,可以从小出发更容易
点赞 评论 收藏
分享
评论
1
19
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务