<!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>
时间: 2024-10-27 13:08:01