js学习(六)- js对象创建
//---------------------js文件---------------------
var namespace02=new Object();
namespace02.Person=function(arg0,arg1,arg2){
this.name=arg0;
this.age=arg1;
this.sex=arg2;
this.showInfo=function(){
alert(this.name+","+this.age+","+this.sex);
}
}
//---------------------html文件---------------------
<!DOCTYPE html>
<html>
<head>
<title></title>
<script type="text/javascript" src="js/Person.js"></script>
<script type="text/javascript">
var p2 = new namespace02.Person("1","2","3");
p2.showInfo();
</script>
</head>
<body>
</body>
</html>