zccst转载+原创
- function Person(){
- var private_name = "小明";
- var private_age = 10;
- this.privilege_name = "小红";
- this.privilege_age = 9;
- }
-
- Person.prototype.public_name = "小芳";
- Person.prototype.public_age = 8;
- Person.static_name = "小李";
- Person.static_age = 7;
-
- var pp = new Person();
- pp.name = ‘小王‘;
- pp.age = 6;
-
-
-
- function Person(){
- var private_name = ‘私有属性‘;
- var private_age = 10;
- this.privilege_name = ‘特权属性‘;
- this.privilege_age = 9;
-
-
- this.showPrivilegeName = function(){
- console.log(private_name);
- console.log(this.privilege_name );
- console.log(this.public_name);
- console.log(Person.static_name);
- }
- }
- Person.prototype.public_name = ‘公有属性‘;
- Person.prototype.public_age = 8;
- Person.static_name = ‘类静态属性‘;
- Person.static_age = 7;
-
-
- var pp = new Person();
- pp.name = ‘小王‘;
- pp.age = 6;
-
- Person.prototype.showName = function(){
-
- console.log(this.privilege_name );
- console.log(this.public_name);
- console.log(Person.static_name);
- }
-
-
-
- console.log(pp.private_name);
- console.log(pp.privilege_name );
- console.log(pp.public_name);
- console.log(Person.static_name);
- console.log(pp.name);
[Object]面向对象编程(高程版)(0)属性和方法
原文:http://www.cnblogs.com/shsgl/p/4289886.html