摘要: prototype是js实现代码共享,继承的利器.1 共享 1 var Person = function(name){ 2 this.name = name; 3 } 4 Person.prototype.pName = function(){ 5 alert(this.name); 6 } 7 8 var p1 = new Person(); 9 var p2 = new Person();10 alert(p1.pName === p2.pName); //true 细节: 1 new Person() 相当于 var obj = {}; //创建... 阅读全文
posted @ 2014-02-07 22:50 _SharpCode 阅读(169) 评论(0) 推荐(0) 编辑