callPerson ±â´ÉÇÔ¼ö´Â ÀÚüÀÇ Àμö·Î ¹ÞÀº IdNumb¸¦ Æ÷ÇÔÇÏ¿©, call ¸Þ¼µå·Î Person ±â´ÉÇÔ¼ö¸¦ È£ÃâÇÏ°í ÀμöµéÀ» Àü´ÞÇÑ´Ù.
µû¶ó¼ Person ±â´ÉÇÔ¼ö ¼Ó¿¡¼´Â this Å°¿öµå´Â Person °¡ ¾Æ´Ï¶ó callPerson °³Ã¼¸¦ ÂüÁ¶ÇÑ´Ù.
ÀÌ ¹æ½ÄÀ¸·Î callPerson °³Ã¼´Â ±× ¼Ó¼ºµéÀ» Person °³Ã¼¿¡ Àü´ÞÇÑ´Ù. ÇÒ´çµÈ ¼Ó¼ºÀº myPerson °³Ã¼¿¡ ¹Ý¿µµÈ´Ù.
<SCRIPT> function Person(pName,gender,birth){ // ±â´ÉÇÔ¼ö¸¦ ¸¸µç´Ù. Person Àº ±â´ÉÇÔ¼ö °³Ã¼ÀÌ´Ù. this.pName=pName; // ¹ÞÀº Àμö¸¦ °³Ã¼ ¼Ó¼º¿¡ ÇÒ´çÇÑ´Ù. this ´Â callPerson ±â´ÉÇÔ¼ö °³Ã¼(myPerson)¸¦ ÂüÁ¶ÇÑ´Ù. this.gender=gender; this.birth=birth; } function callPerson(IdNumb,pName,gender,birth){ // ±â´ÉÇÔ¼ö¸¦ ¸¸µç´Ù. this.IdNumb=IdNumb; // ¹ÞÀº Àμö¸¦ °³Ã¼ ¼Ó¼º¿¡ ÇÒ´çÇÑ´Ù. Person.call(this,pName,gender,birth); // ¼Ó¼ºµéÀ» ±â´ÉÇÔ¼ö Person¿¡ Àμöµé·Î Àü´ÞÇÑ´Ù. //Person.call(this,new Array(pName,gender,birth)); call ¸Þ¼µå¿¡¼´Â arguments ¹è¿º¯¼ö¸¦ ÆĶó¸ÞÅÍ·Î »ç¿ëÇÒ ¼ö ¾ø´Ù. } myPerson=new callPerson(12345,'È«±æµ¿','³²',1900); document.write('È£ÃâÇÑ »ç¶÷Àº ('+myPerson.pName +', '+myPerson.gender +', '+myPerson.birth +')ÀÌ´Ù.'); </SCRIPT>
<SCRIPT> var str=''; // Ãâ·Â ¹®ÀÚ¿ º¯¼ö ¼±¾ð function sub1(pname,gender,birth){ str+='<LI>sub1 ½ÃÀÛ :<BR>arguments='; for(i=0;i<arguments.length;i++) str+=arguments[i]+'; '; // call ¸Þ¼µå´Â arguments¸¦ ÆĶó¸ÞÅÍ·Î Àü´ÞÇÏÁö ¸øÇÑ´Ù. ±×·¯³ª ±â´ÉÇÔ¼ö ÀÚüÀÇ arguments´Â ÂüÁ¶µÈ´Ù. birth='2000'; // º¯¼ö°ªÀ» º¯°æÇÑ´Ù. str+='<BR>'+pname+', '+gender+', '+birth+''; str+='<LI>sub1 Á¾·á'; } function sub0(mark,pname,gender,birth){ str='<OL><LI>sub0 ½ÃÀÛ : '; str+=mark+', '+pname+', '+gender+', '+birth; sub1.call(this,pname,gender,birth); str+='<LI>sub0 Á¾·á'; return str+'</OL>'; } document.write(sub0(12345,'À¯°ü¼ø','¿©','1993')); </SCRIPT>