_TANGTANG

导航

JS的封装

		function Person(name,age){
			//私有变量
			var _name=name;
			function _eat(){
				console.log("eatting...")
			}
			//公有变量
			this.age=age;
			this.sayName=function(){
				console.log(_name);
			}
		}
		var p1=new Person("nicole",24);	

 

 

 

 

 

 

 

 

posted on 2016-09-12 12:08  _TANGTANG  阅读(314)  评论(1编辑  收藏  举报