最近在外头”浪”,当然出去混,总是要有收获的,废话不多,直接来一道关于原型链的问题。 题目 简化题目,大概内容如下: var Tree = function() {}; Tree.prototype.print = function() { console.log(this.leaf++); }; Tree.prototype.leaf = 0; var tree1 = new Tree(); tree1.print(); tree1.print(); var ...
最近在外头”浪”,当然出去混,总是要有收获的,废话不多,直接来一道关于原型链的问题。 题目 简化题目,大概内容如下: var Tree = function() {}; Tree.prototype.print = function() { console.log(this.leaf++); }; Tree.prototype.leaf = 0; var tree1 = new Tree(); tree1.print(); tree1.print(); var ...