Home > Web Front-end > JS Tutorial > Some views on JavaScript object prototype_js object-oriented

Some views on JavaScript object prototype_js object-oriented

WBOY
Release: 2016-05-16 18:19:26
Original
990 people have browsed it

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.

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template