function Hard(str){     var that = {};     that.__proto__ = arguments.callee.prototype ;     that.str = "I am " + str;     setTimeout(that.settime.bind(that));     return that; } Hard.prototype.yanchi = function(m){     console.log("sleep")     var d = new Date();     var n = this._restFirst*1000;     for(var i = 0; i < d; i++){         if( new Date() - d > n ){             console.log("sleep end")             return false;         }     } } Hard.prototype.learn = function( sr ) {     this._learn = sr;     return this; } Hard.prototype.rest = function( num ){     this._rest = num;     return this; } Hard.prototype.restFirst = function ( n ) {     this._restFirst = n;     this._rest = 0;     return this; } Hard.prototype.settime = function(){     var { str, _learn, _rest, _restFirst} = this;     var num = _rest || _restFirst;     if( _restFirst !== undefined ){         this.yanchi();     }else{         console.log(str);     }     if(num){         setTimeout(function(){             console.log( `Start learning after ${ num } seconds` );             if( _restFirst !== undefined ){                 console.log(str);             }             if( _learn ){                 console.log( "Learning " + _learn )             }         },_rest*1000)     } }
1 2

相关推荐

不愿透露姓名的神秘牛友
11-21 11:29
已编辑
斯卡蒂味的鱼汤:知道你不会来数马,就不捞你😂最近数马疯狂扩招,招聘要求挺低的,你能力肯定够,应该就是因为太强了,知道你不会来才不捞你
投递腾讯云智研发等公司7个岗位
点赞 评论 收藏
分享
牛客网
牛客网在线编程
牛客网题解
牛客企业服务