Google
[1536]
 
 
 
 
 
 
 
 
 
 
 
 
¾×¼Ç½ºÅ©¸³Æ®  
 
 
 
 
 
 
 
 
 
 
 

Ajax is more of a technique rather than it is a specific technology.

 

Áö±Ý±îÁöÀÇ Ajax ¿¹Á¦¸¦ »ìÆìº¸¸é ¾Ë°ÚÁö¸¸ Ajax ´Â ÀüÇô »õ·Î¿î ±â¼úÀÌ ¾Æ´Ï´Ù. ±âÁ¸¿¡ À̹̠Á¸ÀçÇØ¿ÔÀ¸³ª Àß ¾²ÀÌÁö ¾Ê¾ÒÀ» »ÓÀÌ´Ù. Ajax ¸¦ »ç¿ëÇÑ´Ù´Â °ÍÀº °á±¹Àº ´Ü¼øÈ­ ÇÏÀÚ¸é ÀÚ¹Ù½ºÅ©¸³Æ®ÀÇ ¿¬Àå¼±À¸·Î ºÁµµ ¹«¹æÇÏ´Ù. µû¶ó¼­ À̹øÀå¿¡¼­´Â ÀÚ¹Ù½ºÅ©¸³Æ®ÀÇ Á»´õ ½ÉÈ­µÈ ÁÖÁ¦¸¦ ¼Ò°³Çغ¼±î ÇÑ´Ù.

 

ÀÚ¹Ù½ºÅ©¸³Æ®´Â 1995³â ³Ý½ºÄÉÀÌÇÁ»çÀÇ Brendan Eich °¡ °í¾ÈÇß´Ù. óÀ½¿¡´Â À¥ÆäÀÌÁö¸¦ ÀÛ¼ºÇÏ´Â À¥ µðÁöÀ̳ʰ¡ ÆíÇÏ°Ô ÀÏÀ» ÇÒ ¼ö ÀÖµµ·Ï ÀÚ¹Ù ¾ÖÇø´À» ±¸ÇöÇØºÃÀ¸³ª, ³ªÁß¿¡´Â ÇÁ·Î±×·¡¹Ö ¾ð¾îÀÇ ÄÄÆÄÀÏ·¯¿Í ÀüÇô »ó°ü¾ø°í ¹®¹ýÀûÀ¸·Îµµ ¸Å¿ì À¯¿¬ÇÑ ¾ð¾î¸¦ ¸¸µé¾î¾ß °Ú´Ù°í °á½ÉÇÏ°Ô µÈ´Ù.

 

ÀÚ¹Ù½ºÅ©¸³Æ®´Â ½ã¿¡¼­ ¸¸µç ÀÚ¹Ù¿Í´Â ÀüÇô »ó°ü¾ø´Â ½ºÅ©¸³Æ® ¾ð¾îÀÌÁö¸¸ À̸§À» ÁöÀ»¶§ ¸¸Å­Àº ½ÃÀå¿¡¼­ ¼º°øÀûÀÎ °¡µµ¸¦ ´Þ¸®°í ÀÖ´Â ÀÚ¹Ù¿¡ °í¹«µÈ ³ª¸ÓÁö ±× À̸§À» ±×³É Â÷¿ëÇØ ¹ö·È´Ù. ÀÚ¹Ù½ºÅ©¸³Æ®´Â ÁøÀÔÀ庮ÀÌ ³ôÁö ¾Ê°í ÆäÀÌÁö¿¡¼­ ÆäÀÌÁö·Î copy and past °¡ ¿ö³« ½¬¿ö¼­ ¾ÆÁÖ ºü¸£°Ô È®»êµÇ¾ú´Ù.

 

³Ý½ºÄÉÀÌÇÁ ÀÚ¹Ù½ºÅ©¸³Æ®¸¦ ´É°¡Çß´ø °ÍÀº ¾Æ´Ï¾úÁö¸¸ MS ´Â ÀÌ¿Í ºñ½ÁÇÑ ±â´ÉÀ» ÇÏ´Â VBScript ¸¦ °í¾ÈÇß´Ù. ÇÏÁö¸¸ ¹®¹ýÀûÀ¸·Î´Â VB ·ÎÁ÷ÀÌ »ç¿ëµÇ¾ú°í IE ¿¡¼­¸¸ »ç¿ëÇÒ ¼ö ÀÖ¾ú´Ù. ¶ÇÇÑ MS ´Â Áö±ÝÀº Ç¥ÁØÀÌ µÇ¾î¹ö¸° ECMAScript, ´Ù¸¥ ¸»·Î JScript ¶ó´Â ÀÚ¹Ù½ºÅ©¸³Æ®¸¦ ¸¸µé¾ú´Ù. ºê¶ó¿ìÀú¸¶´Ù ÀÚ¹Ù½ºÅ©¸³Æ®ÀÇ ±¸ÇöÀº ´ç¿¬È÷ ´Þ¶óÁú ¼ö ¹Û¿¡ ¾ø¾ú´Ù. ºñ·Ï ¹®¹ýÀûÀ¸·Î´Â °ÅÀÇ µ¿ÀÏÇßÁö¸¸ ºê¶ó¿ìÀú »óÈ£°£¿¡ °°Àº ±â´ÉÀ» ±¸ÇöÇϱâ À§ÇÑ ÀÚ¹Ù½ºÅ©¸³Æ® ÄÚµùÀº »ç½Ç °ÅÀÇ ºÒ°¡´ÉÇß´Ù.

 

³Ý½ºÄÉÀÌÇÁ°¡ MS¿ÍÀÇ À¥ºê¶ó¿ìÀú °æÀï¿¡¼­ °í¹è¸¦ ¸¶¼Ì´ø ÀÌÀ¯Áß¿¡, Áö±ÝÀº °á°ú·ÐÀÌ µÇ¾î¹ö·ÈÁö¸¸, 1998³â ³Ý½ºÄÉÀÌÇÁ´Â ÀÚ»ç ºê¶ó¿ìÀúÀÇ ¼Ò½ºÄڵ带 °ø°³ÇÏ¿´°í W3C ÀÇ Ç¥ÁØ¿¡ ¸Â´Â ºê¶ó¿ìÀú¸¦ ¸¸µé±â À§Çؼ­ ¹Ø¹Ù´ÚºÎÅÍ ´Ù½Ã ¸¸µé±â·Î °áÁ¤Çß´Ù´Â Á¡°ú ÀÌÈÄ ÈÄ¼Ó ¸ðµ¨ÀÌ ³Ê¹« ´Ê°Ô Ãâ½ÃµÇ¾ú´Ù´Â Á¡À» µé ¼ö ÀÖ´Ù. ³Ý½ºÄÉÀÌÇÁÀÇ »õ·Î¿î ¸ðµ¨ Ãâ½Ã°¡ ´Ê¾îÁø °ÍÀº ´Ù¸¥ ¿©·¯ ¿øÀÎÀÌ ÀÖ°ÚÀ¸³ª Å« ¸Æ¶ô¿¡¼­ º¸ÀÚ¸é ÀÚÃæ¼ö°¡ ¾Æ´Ï¾ú³ª ½Í´Ù. ÀÌ ½Ã±â´Â MS IE5°¡ W3C ¿Í ECMAScript Ç¥ÁØÀ» Àß µû¸£¸ç ½ÃÀåÀ» ¼®±ÇÇϰí ÀÖÀ» ¶§¿´´Ù. ¸ðÁú¶ó Áø¿µ¿¡¼­´Â 2002³âÀÌ µÇ¾î¼­¾ß ºñ·Î¼Ò ³Ý½ºÄÉÀÌÇÁÀÇ ¿ÀǼҽº Ã¹ ¿Ï¼ºÇ° ¹ßÇ¥Çß´Ù. À̽ÃÁ¡ÀÌ Áß¿äÇÏ´Ù. À̶§¾ß ºñ·Î¼Ò »õ·Î ¸¸µé¾îÁö´Â À¥ ºê¶ó¿ìÀúµéÀº W3C ¿Í ECMAScript ÀÇ Ç¥ÁØÀ» ÁؼöÇϱ⠽ÃÀÛÇß´Ù. IE ¸¦ Á¦¿ÜÇÑ ÇöÁ¸Çϴ ¸ðµç ºê¶ó¿ìÀúµé(FireFox, Mozilla, Opera, Konquerer, Safari) Àº À¥ Ç¥ÁØÀ» ¾ÆÁÖ Àß µû¸£°í ÀÖ´Ù. IE6 Àº 1998³âÀÇ IE5¿Í °ÅÀÇ º¯ÇѰÍÀÌ ¾øÀ» Á¤µµ·Î ¼¼»óÀÇ ¸ðµç ºê¶ó¿ìÀúµé¿¡°Ô °Å¸¸ÇÔÀ» º¸À̰í ÀÖ´Ù.

 

ÀÚ¹Ù½ºÅ©¸³Æ®´Â »ó¼ÓÀ» Áö¿øÇÑ´Ù. ÇÏÁö¸¸ ´Ù¸¥ °´Ã¼ÁöÇâ ¾ð¾îÀÇ Å¬·¡½º°£ »ó¼Ó°³³äÀÌ ¾Æ´Ñ ¸µÅ©°³³äÀ̶ó´Â Á¡ÀÌ Â÷À̰¡ ÀÖ´Ù. ¸µÅ©°³³äÀÌ ¹«¾ùÀΰ¡ ÇÏ¸é ´ÙÀ½°ú °°´Ù. °¢°¢ÀÇ ÀÚ¹Ù½ºÅ©¸³Æ® °´Ã¼´Â prototype À̶ó´Â ³»Àå ¼Ó¼ºÀ» °¡Áö°í ÀÖ´Ù. prototype ¼Ó¼ºÀº ´Ù¸¥ ÀÚ¹Ù½ºÅ©¸³Æ® °´Ã¼ÀÇ ·¹ÆÛ·±½º¸¦ ±â¾ïÇϰí ÀÖ´Ù. Áï ÀÚ¹Ù½ºÅ©¸³Æ®¿¡¼­ÀÇ »ó¼ÓÀº prototype ¼Ó¼ºÀ» ÀÌ¿ëÇØ¼­ ±¸Çö°¡´ÉÇÏ´Ù. Àá½Ã µÚ¿¡ »ìÆìº¼ ¿¹Á¦¸¦ º¸¸é ¾Ë°ÚÁö¸¸ ÀϹÝÀûÀÎ °´Ã¼ÁöÇâ ¾ð¾î¿¡¼­ »ó¼ÓÀÌ is a °ü°è¶ó¸é, ÀÚ¹Ù½ºÅ©¸³Æ®¿¡¼­ »ó¼ÓÀº prototype À» ÀÌ¿ëÇÑ has a °ü°èÀÌ´Ù. (ÀϹÝÀûÀÎ °´Ã¼ÁöÇâ ¾ð¾î¿¡¼­  is a °ü°è´Â »ó¼ÓÀ» ÀǹÌÇϰí, has a °ü°è´Â ÂüÁ¶¸¦ ÀǹÌÇÑ´Ù.)

 

<Ŭ·¡½º ´Ù¾î¾î±×·¥>

 

À§ ±×¸²À» º¸¸é SportsCar ¿Í CementTruck µÎ Ŭ·¡½º´Â Vehicle Ŭ·¡½º¸¦ »ó¼Ó¹Þ°í ÀÖ´Ù. SportsCar ÀÇ °æ¿ì curbWeigtInPounds(¹«°Ô) ¸¦ 3000À¸·Î Àç ¼³Á¤Çß°í wheelCount(¹ÙÄû¼ö) ´Â ºÎ¸ðÀÇ ¼ºÁúÀÎ 4¸¦ °¡Áö°í ÀÖÀ» °ÍÀÌ´Ù. ³ª¸ÓÁö µÎ ¸Þ¼ÒµåÀÎ refuel ¹× mainTasks ´Â ÀçÁ¤ÀÇÇØ¼­ »ç¿ëÇϰí ÀÖ´Ù.

 

CementTruck Àº ¸ðµç ¸â¹ö°ªÀ» Àç¼³Á¤ÇßÀ¸¸ç, ¸ðµç ¸Þ¼Òµå ¶ÇÇÑ ÀçÁ¤ÀÇÇØ¼­ »ç¿ëÇϰí ÀÖ´Ù.

 

ÀÚ¹Ù½ºÅ©¸³Æ®¿¡¼­´Â ÀϹÝÀûÀÎ °´Ã¼ÁöÇâ ¾ð¾îÀÇ Æ¯Â¡ÀΠÀÎÅÍÆäÀ̽º³ª Ãß»óŬ·¡½ºÀÇ °³³äÀÌ ¾ø´Ù. ±×·¯¸é À§ Ŭ·¡½º ´ÙÀ̾î±×·¥¿¡ ¸Â´Â ¼Ò½ºÄڵ带 »ìÆìº¸ÀÚ.

 

/* Constructor function for the Vehicle object */
function Vehicle() { }

/* Standard properties of a Vehicle */
Vehicle.prototype.wheelCount = 4;
Vehicle.prototype.curbWeightInPounds = 4000;

/* Function for refueling a Vehicle */
Vehicle.prototype.refuel = function() {
    return "Refueling Vehicle with regular 87 octane gasoline";
}

/* Function for performing the main tasks of a Vehicle */
Vehicle.prototype.mainTasks = function() {
    return "Driving to work, school, and the grocery store";
}


/* Constructor function for the SportsCar object */
function SportsCar() { }

/* SportsCar extends Vehicle */
SportsCar.prototype = new Vehicle();

/* SportsCar is lighter than Vehicle */
SportsCar.prototype.curbWeightInPounds = 3000;

/* SportsCar requires premium fuel */
SportsCar.prototype.refuel = function() {
    return "Refueling SportsCar with premium 94 octane gasoline";
}

/* Function for performing the main tasks of a SportsCar */
SportsCar.prototype.mainTasks = function() {
    return "Spirited driving, looking good, driving to the beach";
}


/* Constructor function for the CementTruck object */
function CementTruck() { }

/* CementTruck extends Vehicle */
CementTruck.prototype = new Vehicle();

/* CementTruck has 10 wheels and weighs 12,000 pounds*/
CementTruck.prototype.wheelCount = 10;
CementTruck.prototype.curbWeightInPounds = 12000;

/* CementTruck refuels with diesel fuel */
CementTruck.prototype.refuel = function() {
    return "Refueling CementTruck with diesel fuel";
}

/* Function for performing the main tasks of a SportsCar */
CementTruck.prototype.mainTasks = function() {
    return "Arrive at construction site, extend boom, deliver cement";
}

<inheritanceViaPrototype.js ÀÇ Àüü ¼Ò½ºÄÚµå>

 

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>JavaScript Inheritance via Prototype</title>

<script type="text/javascript" src="inheritanceViaPrototype.js"></script>

<script type="text/javaScript">

function describe(vehicle) {
    var description = "";
    description = description + "Number of wheels: " + vehicle.wheelCount;
    description = description + "\n\nCurb Weight: " + vehicle.curbWeightInPounds;
    description = description + "\n\nRefueling Method: " + vehicle.refuel();
    description = description + "\n\nMain Tasks: " + vehicle.mainTasks();
    alert(description);
}

function createVehicle() {
    var vehicle = new Vehicle();
    describe(vehicle);
}

function createSportsCar() {
    var sportsCar = new SportsCar();
    describe(sportsCar);
}

function createCementTruck() {
    var cementTruck = new CementTruck();
    describe(cementTruck);
}
</script>
</head>

<body>
  <h1>Examples of JavaScript Inheritance via the Prototype Method</h1>
 
  <br/><br/>
  <button onclick="createVehicle();">Create an instance of Vehicle</button>
 
  <br/><br/>
  <button onclick="createSportsCar();">Create an instance of SportsCar</button>
 
  <br/><br/>
  <button onclick="createCementTruck();">Create an instance of CementTruck</button>

</body>
</html>


 

<inheritanceViaPrototype.html ÀÇ Àüü ¼Ò½º ÄÚµå>

 

¿ì¼± inheritanceViaPrototype.js ÆÄÀÏ¿¡¼­ Vehicle Ŭ·¡½º¸¦ Á¤ÀÇÇÏ´Â ºÎºÐÀ» »ìÆìº¸ÀÚ.

function Vehicle() { }

=> ÀÚ¹Ù½ºÅ©¸³Æ®¿¡¼­ Ŭ·¡½º¸¦ Á¤ÀÇÇÒ ¶§ ¸Þ¼Òµåó·³ Á¤ÀÇÇÑ´Ù.

 

Vehicle.prototype.wheelCount = 4;

=> ¸â¹ö¿¡ °ªÀ» ÇÒ´çÇÒ¶§ prototype ¼Ó¼ºÀ» ÀÌ¿ëÇÑ´Ù.

 

Vehicle.prototype.refuel = function() {
    return "Refueling Vehicle with regular 87 octane gasoline";
}

=> ¸Þ¼Òµå¸¦ Á¤ÀÇÇÒ¶§µµ prototype ¼Ó¼ºÀ» ÀÌ¿ëÇÑ´Ù.

 

function SportsCar() { }

SportsCar.prototype = new Vehicle();

=> ºÎ¸ð Ŭ·¡½º¸¦ »ó¼Ó¹Þ´Â SportCar ÀÇ °æ¿ì Ŭ·¡½º Á¤ÀÇÇÏ´Â ºÎºÐÀº Vehicle°ú °°À¸³ª »ó¼ÓÀ» Ç¥ÇöÇÏ´Â ºÎºÐÀº prototype ¼Ó¼ºÀ» ÀÌ¿ëÇÏ°í ºÎ¸ð Ŭ·¡½ºÀÇ ÀνºÅϽº¸¦ »ý¼ºÇؼ­ ÇÒ´çÇÑ´Ù.

 

SportsCar.prototype.curbWeightInPounds = 3000;

=> ¸â¹öÀÇ °ªÀ» ÇÒ´çÇÒ¶§µµ prototype À» ÀÌ¿ëÇÑ´Ù.

 

SportsCar.prototype.refuel = function() {
    return "Refueling SportsCar with premium 94 octane gasoline";
}

=> ¸â¹ö ¸Þ¼Òµå¸¦ Àç Á¤ÀÇÇÒ¶§µµ prototype À» ÀÌ¿ëÇÑ´Ù.

 

À§ Äڵ带 º¸¸é ÀÚ¹Ù½ºÅ©¸³Æ®¿¡¼­ »ó¼ÓÀÌÁö¸¸ prototype ¼Ó¼ºÀ» ÀÌ¿ëÇÑ ÂüÁ¶¹æ½ÄÀ¸·Î ±¸ÇöµÊÀ» ¾Ë ¼öÀÖ´Ù.

 

À§  inheritanceViaPrototype.html ¸¦ À¥¼­¹ö¿¡¼­ ½ÇÇàÇØº¸¸é ¾Æ·¡¿Í °°Àº °á°ú¸¦ È®ÀÎ ÇÒ ¼ö ÀÖ´Ù. 

 

 


 

<inheritanceViaPrototype.html À» ½ÇÇàÇÑ È­¸é>

 

 

 


 

<Create an instance of Vehicle ¹öưÀ» ´­·¶À» ¶§ÀÇ °á°ú>

 

 


 

<Create an instance of SportsCar ¹öưÀ» ´­·¶À» ¶§ÀÇ °á°ú>

 

 


 

<Create an instance of CementTruck ¹öưÀ» ´­·¶À»¶§ÀÇ °á°ú>