javascript ÔÐͶÔÏóÓëprototypeµÄ¹Øϵ
JavascriptÖеļ̳лúÖÆÊÇËùνµÄÔÐͶÔÏó¼Ì³Ð£¬Í¨¹ýÊôÐÔ·ÃÎÊ»úÖƵÄÌØÊâÐÔÀ´ÊµÏּ̳еġ£Ö®Ç°ÎÒÒ»Ö±ÒÔΪËùÓжÔÏóµÄÔÐͶÔÏó¾ÍÊÇprototypeËùÖ¸µÄÄǸö¶ÔÏ󡣺óÀ´ÔÚ¿´javascriptÉè¼ÆģʽµÄʱºò·¢ÏÖ×÷Õß×¢ÖÐÓÐÒ»¾ä»°ÓëÎÒ֮ǰµÄÀí½â²»Í¬£¬Ëû˵“ÿ¸ö¶ÔÏó¶¼ÓÐÒ»¸öÔÐͶÔÏ󣬵«Õâ²¢²»Òâζ×Åÿ¸ö¶ÔÏó¶¼ÓÐÒ»¸öprototypeÊôÐÔ”¡£¿´ÍêÎÒ¾ÍÓеãÃÔãÁË£¬¾ö¶¨³¹µ×°ÑÕâ¸öËÀÈ˵ÄÔÐͼ̳иã¸ãÇå³þ¡£È»ºó·ÁËЩÎÄÕºÍÊé¼®£¬×îºóÖÕÓÚÔÚjavascriptȨÍþÖ¸ÄϵÚÎå°æÖÐÕÒµ½Á˸öÈË ÈÏΪ±È½ÏȨÍþµÄ½âÊÍ¡£¹ØÓÚÔÐÍÁ´ºÍÊôÐÔ·ÃÎÊ»úÖÆÎҾͲ»ÔÙ²ûÊöÁË£¬Õâ·½Ãæ¿ÉÒÔ¿´¿´RockyµÄÎÄÕ дµÄÂùÇå³þµÄ http://blog.csdn.net/rocky_j2ee/archive/2009/03/21/4012385.aspx
ÄÇÎÒÃÇÏÈ´Ó´´½¨¶ÔÏó˵Æð£¬ÓÃnew²Ù×÷·û´´½¨¶ÔÏóµÄʱºòjavascript»á×ö3¼þÊ£º
Ê×ÏÈÊÇ´´½¨Ò»¸ö¿Õ¶ÔÏó£¨empty object£©£¬
È»ºó¶ÔÕâ¸ö¿Õ¶ÔÏóµÄÔÐͶÔÏó½øÐи³Öµ£¬
×îºó°ÑÕâ¸ö¿Õ¶ÔÏó¸³Öµ¸ø¹¹Ô캯ÊýµÄthisÊôÐÔÇÒÔËÐÐÕâ¸ö¹¹Ô캯Êý¡£
function Person(name) {
this.name = name;
}
var p = new Person(); Ï൱ÓÚÒÔϲ½Ö裺
1. Var p = {};
2. p.[[prototype]] = Person.prototype //ÕâÒ»²½ÊÇα´úÂ룬ʵ¼ÊÉÏÒ»¸ö¶ÔÏóµÄÔÐͶÔÏóÊDz»ÄÜͨ¹ý´úÂëÀ´·ÃÎʵģ¬
//ÕâÀïÖ»ÊÇΪÁË˵Ã÷´´½¨¶ÔÏóµÄ²½Öè
3. p.methodName = Person //ÕâÑùµÄ»°PersonµÄthis¾Í»áÖ¸Ïòp
p.methodName();
Èç¹ûÄã¶ÔµÚ¶þ²½²»ÊǺÜÃ÷°×£¬ÄÇôÏÈ°Ñ´úÂë·ÅÒ»·Å£¬½ÓÏÂÀ´ÎÒ»áÏêϸ½âÊÍϵڶþ²½ÔÐͶÔÏóµÄ¸³Öµ£¨»òÕß˵¹¹Ô캯ÊýºÍÔÐͶÔÏóµÄ¹Øϵ£©:
ÉÏÃæÎÒÌáµ½¹ýÔÚ´´½¨ÍêÒ»¸ö¿Õ¶ÔÏóºó£¬»á³õʼ»¯Õâ¸ö¿Õ¶ÔÏóµÄÔÐͶÔÏó£¬javascript»á°Ñ¹¹Ô캯ÊýµÄÒ»¸ö½Ð×öprototypeµÄÊôÐÔËùÖ¸ÏòµÄ¶ÔÏó¸³Öµ¸øµ±Ç°¿Õ¶ÔÏóµÄÔÐͶÔÏó¡£ËùÓеÄfunction¶¼ÓÐÒ»¸öprototypeÊôÐÔ£¬µ±Ò»¸öfunction±»¶¨ÒåÖ®ºóÕâ¸öÊôÐԻᱻ×Ô¶¯µÄ´´½¨ºÍ³õʼ»¯¡£Ò»¸öfunction µÄprototypeÊôÐԵijõʼֵÊÇÒ»¸ö¶ÔÏó£¨an object£©£¬Õâ¸ö¶ÔÏóÖ»ÓÐÒ»¸öÊôÐÔ½Ð
Ïà¹ØÎĵµ£º
/**
* JavaScript ÊÇÃæÏò¶ÔÏóµÄÓïÑÔ£¬µ«ÊÇËûµÄÃæÏò¶ÔÏó²»ÊÇ»ùÓÚÀàµÄ£¬ÊÇ»ùÓÚÔÐ͵Ä;
* µ«ÊÇËûµÄһЩÌØÐÔ(º¯ÊýÊÇÊý¾Ý)£¬Ê¹µÃËü¿ÉÒÔÄ£Äâ»ùÓÚÀàµÄÃæÏò¶ÔÏ󣬵«ÊÇ JavaScript ²¢²»Ö§³ÖºÍ Java Ò»ÑùµÄÀ࣬
* Òò´Ë JavaScript ÖеÄ"Àà"¿ÉÒÔ³Æ×÷"αÀà"
*/
//
/**
* ¹¹Ô캯Êý: js ÖÐÓÃÀ´ºÍ new ÔËËã·ûÒ»ÆðʹÓõĺ¯Êý³Æ× ......
calcu() ----º¯ÊýʵÏÖÁ½¸öÊýÏà³Ë
document.write(); ---´òÓ¡
document.calc.ÔªËØÃû.value; --»ñµÃ±íµ¥µÄÖµ
document.±íµ¥Ãû¡£±íµ¥ÔªËØÃû¡£value Ϊ±íµ¥¸³Öµ
¶¨Ò庯Êý£º
function Ãû×Ö()
{
//javaScriptÔ¤Óï¾ä
}
onClick="º¯ÊýÃû";  ......
<html>
<mce:script type="text/javascript"><!--
function checkedAll(checked)
{
var ckbArray=document.getElementsByName('ckb');
for(var i=0,len=ckbArray.length;i<len;i++)
{
ckbArray[i].checked=checked;
}
}
function clickbutton()
{
var ckbArra ......
ÓÐʱºòÕÒµ½±ðÈËдµÄjs´úÂëÊÇѹËõ¹ýµÄ£¬Í¨¹ýÕâ¸ö¹¤¾ß¿ÉÒÔ¶Ô´úÂë½øÐиñʽ»¯¡£
<html>
<head>
<title>JS¸ñʽ»¯¹¤¾ß </title>
<meta http-equiv="content-type" content="text/html; charset=gb2312" />
<mce:style><!--
* { padding:0px; margin:5px; font-size:13px; font-fami ......