//原型对象的练习 //定义一个空的类型 function Person(){ } //通过类型名.prototype获取到的原型(),给原型动态的添加属性 Person.prototype.names = "黄渤"; Person.prototype.age = 39; Person.prototype.address = "北京"; Person.prototype.showInfo = function(){ alert(this.names+"\n"+this.age+"\n"+this.address); } var p1 = new Person(); p1.showInfo(); var p2 = new Person(); p2.names = "黄晓明 "; p2.age = 35; p2.address = "山东青岛"; p2.showInfo();
关于原型对象的理解加案例
猜你喜欢
转载自www.cnblogs.com/www-yang-com/p/9253837.html
今日推荐
周排行