함수의 봉인

8812 단어 함수

  
  
<! DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd" >
< html >
< head >
< meta http-equiv ="Content-Type" content ="text/html; charset=iso-8859-1" >
< title > Untitled Document </ title >
< script type ="text/javascript" >
function CreatePerson(name,sex,birthday,fn)
{
this .name = name;
this .sex = sex;
this .birthday = birthday;
}
CreatePerson.prototype.sayHi
= function (name)
{
alert(
" Hi ! I am " + this .name);
alert(name);
}

var person1 = new CreatePerson( ' zs ' , ' boy ' , ' 2001-02-03 ' );
var person2 = new CreatePerson( ' ls ' , ' boy ' , ' 2001-02-04 ' );
person1.sayHi(
' 111111111111 ' ); // outputs "Hi ! I am zs"
person2.sayHi(); // outputs "Hi ! I am ls"
</ script >
</ head >
< body >
</ body >
</ html >

좋은 웹페이지 즐겨찾기