1、说明
利用空对象作为中介,将某个对象直接分配给空对象构造函数的原型。
2、缺点
原型链继承多个实例的引用类型属性指向相同,可能会被篡改。
不能传递参数。
3、实例
varperson={ name:"Nicholas", friends:["Shelby","Court","Van"] }; varanotherPerson=object(person); anotherPerson.name="Greg"; anotherPerson.friends.push("Rob"); varyetAnotherPerson=object(person); yetAnotherPerson.name="Linda"; yetAnotherPerson.friends.push("Barbie"); alert(person.friends);//"Shelby,Court,Van,Rob,Barbie"原文来自:https://www.py.cn
© 版权声明
文章版权归作者所有,未经允许请勿转载。
THE END
暂无评论内容