<!DOCTYPE html>
<html>
<head>
<title></title>
<meta charset="utf-8" />
<script type="text/javascript">
function test(){
var a = 100;
this.b = 200;
//私有方法
function getMax(){
alert(1);
}
//公有方法
this.getMin = function (){
alert(2);
}
}
var obj = new test;
obj.b;
obj.getMin();//公有方法可以调出,值为2
//obj.getMax();//私有方法调不出
</script>
</head>
<body>
</body>
</html>本文出自 “IT5808” 博客,请务必保留此出处http://it5808.blog.51cto.com/10842703/1713238
原文:http://it5808.blog.51cto.com/10842703/1713238