js學習(六)- js對象建立

//---------------------js文件---------------------javascript

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

 

//---------------------html文件---------------------java

<!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();this

</script>
</head>
<body>spa

</body>
</html>htm

相關文章
相關標籤/搜索