new+1个人实现和理解,使用原型中的属性来记录: let cl = function (name) { this.name = name if (this instanceof cl) { if (cl.prototype.count !== undefined) { cl.prototype.count++ } else { cl.prototype.count = 0 } } this.count = cl.prototype.count } console.log(new cl(1)) cl() console.log(new cl(2))
点赞 评论

相关推荐

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