js工場モード(構造関数を利用して)
3349 ワード
<!DOCTYPE HTML>
<html>
<head>
<title>please enter your title</title>
<meta charset="utf-8">
<meta name="Author" content=" ">
<style type='text/css'> *{ margin:0; padding:0;} </style>
</head>
<body>
<script type="text/javascript"> /* new : , new : this ; */ // ( ) function Person( name ){ this.name = name; this.showName = function(){ alert( this.name ); } } var obj1 = new Person('Eva'); var obj2 = new Person(' '); var obj3 = new Person(' '); var obj4 = new Person(' '); alert( obj1.showName == obj2.showName ) //obj1.showName(); </script>
</body>
</html>