Home >Web Front-end >JS Tutorial >Some views on JavaScript object prototype_js object-oriented
1. function func() {
this.name = "huhao";//This variable is private and can only be accessed when creating a new object, such as var obj= new func(); obj. The name is accessible and can be modified, but it can only be modified in the new object,
}
func.age="11"; //This variable cannot be inherited, only func. age to access
func.prototype.address="Anhui Province";//This variable cannot be accessed directly by func.address, but can only be accessed by var obj= new func(); obj.address, and at the same time in obj. address can be modified
Conclusion:
1. The name and address objects are private and invisible. However, newly constructed objects are developed.
2.age attribute is private, visible and cannot be inherited.