°³Ã¼°¡ ƯÁ¤ Ŭ·¡½ºÀÇ ÀνºÅϽºÀÎÁö ¿©ºÎ¸¦ ³ªÅ¸³»´Â ºÎ¿ï°ªÀ» ¹ÝȯÇÑ´Ù.
result=object instanceof class
instanceof ¿¬»êÀÚ´Â ¸¸¾à object°¡ classÀÇ ÀνºÅϽºÀ̸é true¸¦ ¹ÝȯÇÑ´Ù.
object°¡ ÁöÁ¤µÈ Ŭ·¡½ºÀÇ ÀνºÅϽº°¡ ¾Æ´Ï°Å³ª object°¡ nullÀ̸é false¸¦ ¹ÝȯÇÑ´Ù.
<SCRIPT> function area(x,y){ return x*y; } function string(s){ return ('¹®ÀÚ¿['+ s + ']'); } var newSqr = new area; document.write ('var newSqr = new area<BR><BR>'); document.write ('newSqr <FONT color=brown>instanceof</FONT> area<BR>'); document.write(newSqr +' <FONT color=red>instanceof</FONT> '+area+' '); document.write('<FONT color=blue><B>'+(newSqr instanceof area)+'</B></FONT><BR><BR>'); document.write ('newSqr <FONT color=brown>instanceof</FONT> string<BR>'); document.write(newSqr +' <FONT color=red>instanceof</FONT> '+string+' '); document.write('<FONT color=blue><B>'+(newSqr instanceof string)+'</B></FONT><BR><BR>'); </SCRIPT>
<SCRIPT> function objTest(obj){ var i,myArray,str=''; // º¯¼ö¸¦ ¸¸µç´Ù. myArray=new Array(); // ¹è¿À» ¸¸µç´Ù. myArray['Date']=Date; // ¹è¿À» ä¿î´Ù. myArray['Object']=Object; myArray['Array']=Array; for (i in myArray){ if (obj instanceof myArray[i]){ // obj Ŭ·¡½º¸¦ °Ë»çÇÑ´Ù. str+='obj´Â '+i+'ÀÇ ÀνºÅϽºÀÌ´Ù.<BR>'; } else { str +='obj´Â '+i+'ÀÇ ÀνºÅϽº°¡ ¾Æ´Ï´Ù.<BR>'; } } return (str); // ¹®ÀÚ¿À» ¹ÝȯÇÑ´Ù. } var obj=new Date(); // »õ·Î¿î ³¯ÀÚ °³Ã¼¸¦ ¸¸µë document.write(objTest(obj)); // ±â´ÉÇÔ¼ö¸¦ ÅëÇÑ °á°ú Ãâ·Â </SCRIPT>