javascript 学习笔记 三大特性

<script type="text/javascript">
//封装
 function Person (name,age,sal){
 	this.name=name;//公开的
 	var age=age;//私有属性
 	var sal=sal;
 	//公开方法
   this.fun=function (){
   	alert(sal);
   	test();
   }

   //私有方法
   function test(){
   	alert(age);
   }
 }
 //在类中定义公开的方法
   var p1=new Person('hh',25,3600);
   // alert(p1.age);
   p1.fun();

</script>

 

posted @ 2013-11-24 23:52  闲云-野鹤  阅读(175)  评论(0编辑  收藏  举报