SOURCE

//构造器模式特权方法
function Person(name){
		this.getName = function(){
     	return name; 
    }
		
		this.setName = function(value){
			name = value;
		};
	}	
	var person = new Person("Nicholas");
	alert(person.getName());		//"Nicholas"
	person.setName("Greg");
	alert(person.getName());		//"Greg"
	// alert(person.name);   undefine


//原型模式特权方法
(function(){
		var name ="";
		
		Person = function(value){
			name = value;
		};
		
		Person.prototype.getName = function(){
			return name;
		};
		
		Person.prototype.setName = function(value){
			name = value;
		};
	})();
	
	var person1 = new Person("Nicholas");
	alert(person1.getName());	//"Nicholas"
	person1.setName("Greg");
	alert(person1.getName());	//"Greg"
	
	var person2 = new Person("Michael");
	alert(person1.getName());	//"Michael"
	alert(person2.getName());	//"Michael"
console 命令行工具 X clear

                    
>
console