¡¶Îò͸javascript¡·Ñ§Ï°±Ê¼Ç£º¾Å¡¢ÔÐͱ϶
ÒýÑÔ
prototypeÔ´×Ô·¨ÓÈí¼þ½çµÄ±ê×¼·ÒëΪ“ÔÐÍ”£¬´ú±íÊÂÎïµÄ³õʼÐÎ̬£¬Ò²º¬ÓÐÄ£ÐͺÍÑù°åµÄÒâÒå¡£
prototypeÊôÐÔ
JavaScriptµÄËùÓÐfunctionÀàÐ͵ĶÔÏó¶¼ÓÐÒ»¸öprototypeÊôÐÔ¡£Õâ¸öprototypeÊôÐÔ±¾ÉíÓÖÊÇÒ»¸ö object ÀàÐ͵ĶÔÏó£¬Òò´ËÎÒÃÇÒ²¿ÉÒÔ¸øÕâ¸ö prototype ¶ÔÏóÌí¼ÓÈÎÒâµÄÊôÐԺͷ½·¨¡£¼ÈÈ» prototypeÊǶÔÏóµÄ“ÔÐÍ”£¬ÄÇôÓɸú¯Êý¹¹Ôì³öÀ´µÄ¶ÔÏóÓ¦¸Ã¶¼»á¾ßÓÐÕâ¸ö“ÔÐÍ”µÄÌØÐÔ¡£ÊÂʵÉÏ£¬ÔÚ¹¹Ô캯ÊýµÄprototypeÉ϶¨ÒåµÄËùÓÐÊôÐԺͷ½·¨£¬¶¼ÊÇ¿ÉÒÔͨ¹ýÆä¹¹ÔìµÄ¶ÔÏóÖ±½Ó·ÃÎʺ͵÷Óõġ£Ò²¿ÉÒÔÕâô˵£¬prototypeÌṩÁËһȺͬÀà¶ÔÏó¹²ÏíÊôÐԺͷ½·¨µÄ»úÖÆ¡£ÔËÐÐÈçÏ´úÂ룬Ȼºó¹Û²ì¡£
<script language="javascript">
function person(name){ //¹¹Ô캯Êýperson
this.name = name;
//this´´½¨³öµÄ¶ÔÏó£¬Ã¿Ò»¸ö¸±±¾¶¼»á°üº¬ÆäÊôÐԺͺ¯Êý
this.say = function(){alert("hello, i'm " + this.name);}
}
//prototype´´½¨µÄº¯Êý¶ÔÏó£¬ËùÓеĸ±±¾¹²Ïíͬһ¸öº¯Êý
person.prototype.show = function(){alert("hi~~, i'm " + this.name);}
var p1 = new person("p1");
var p2 = new person("p2");
alert(p1.say == p2.say); //false£¬Ã»¹²Ïíº¯Êý
alert(p1.show == p2.show); //true£¬¹²Ïíº¯Êý
</script>
ÔÐÍÁ´
<script language="javascript">
function person(name){
this.name = name;
}
person.prototype.say = function(){alert("hello, i'm " + this.name);}
function employee(name, salary){
//µ÷ÓÃperson×÷ΪemployeeµÄ¹¹Ô캯Êý——Öصã
person.call(this, name); //Ä¿µÄÊǼ̳ÐpersonµÄÊôÐÔ
this.salary = salary;
}
//×ÓÀ๹Ô캯ÊýÊ×ÏÈÐèÒªÓÃÉϲ㹹Ô캯ÊýÀ´½¨Á¢ prototype¶ÔÏó£¬ÊµÏּ̳еĸÅÄî——Öصã
employee.prototype = new person(); //Ä¿µÄÊǼ̳ÐpersonµÄ·½·¨£¬Ö»ÐèÒªÆä prototype µÄ·½·¨£¬´Ë¶ÔÏóµÄ³ÉԱûÓÐÈκÎÒâÒ壡
employee.prototype.showMoney = function(){alert(this.name + "'s salary is " + this.salary);}
var bill = new pers
Ïà¹ØÎĵµ£º
Ò»¡¢ºǫ́£¨.csÎļþ£©·½·¨£º
public string GetString(string name)
{
return ("Hello " + name);
}
&n ......
JavaScriptʼþ·ÖÀࣺ
1¡¢²¶»ñÐÍ£¨IE²»Ö§³Ö£©£¨´ÓDOM½á¹¹µÄ×¶Ë¿ªÊ¼ÏòÏÂÑÓÉ죩
2¡¢Ã°ÅÝÐÍ£¨´ÓDOM½á¹¹µÄ×îµÍ¶ËÏòÉÏÒ»¼¶¼¶ÑÓÉ죩
¡¾IE7ÒÔÉÏ¿ÉÒÔ¸ø‘html’Ìí¼Óonclickʼþ£¬IEÖÐbody->html£¬»ðºüÖÐhtml->body¡¿
JavaScriptÌí¼Óʼþ¼àÌý£º
1¡¢IE£º
[object].attachEvent("event_handler", fnHandler); ......
history¶ÔÏó3¸ö·½·¨back()¡¢forward()ºÍgo()£¬ÕâЩ·½·¨¿ÉÒÔµ÷ÓÃÀúÊ·±íÖаüº¬µÄÎĵµ¡£
back()·½·¨×°ÈëÀúÊ·±íÖеÄÇ°Ò»¸öÒ³Ã棬µÈЧÓÚä¯ÀÀÆ÷ÖеÄBack°´Å¥
forward()·½·¨×°ÈëÀúÊ·±íÖеĺóÒ»¸öÒ³Ã棬µÈЧÓÚä¯ÀÀÆ÷ÖеÄForward°´Å¥
go()·½·¨½øÈëÀúÊ·±íÖеÄÌض¨Îĵµ£¬¿ÉÒÔÈ¡ÕûÐβÎÊý»ò×Ö·û´®²ÎÊý
go(n)n>0ʱ£¬×°ÈëÀúÊ·±íÖÐµÄ ......
ÒýÑÔ
ÒªÀí½â JavaScript£¬ÄãµÃÊ×ÏÈ·Å϶ÔÏóºÍÀàµÄ¸ÅÄ»Øµ½Êý¾ÝºÍ´úÂëµÄ±¾Ô¡£Ç°Ãæ˵¹ý£¬±à³ÌÊÀ½çÖ»ÓÐÊý¾ÝºÍ´úÂëÁ½ÖÖ»ù±¾ÔªËØ£¬¶øÕâÁ½ÖÖÔªËØÓÖÓÐמÀ²ø²»ÇåµÄ¹Øϵ¡£JavaScript¾ÍÊÇ°ÑÊý¾ÝºÍ´úÂ붼¼ò»¯µ½×îÔʼµÄ³Ì¶È¡£
»ù±¾ÀàÐÍ
Ò»¡¢¼òµ¥Êý¾ÝÀàÐÍ£ºundefined¡¢null¡¢boolean¡¢number¡¢string£¨×¢Ò⣺¶¼Ê ......
ÒýÑÔ
JavaScriptûÓÐ “Àà”µÄ¸ÅÄÕâÈúܶàѧϰ¹ý¸ß¼¶ÓïÑÔµÄÈ˸е½ºÜ²»Ë¬£¬Æäʵ±ÈÖ®ÓÚCÓïÑÔÓÖÈçºÎÄØ£¿ÏÔÈ»JavaScriptÒª±ÈCÓïÑÔºÃÓúܶࡣ
²»·Ï»°£¬ÉÏ´úÂë
<script language="javascript">
/*Ò»¾ä¾äµÄ¿´¸üÈÝÒ×Ã÷°×*/
//ÉùÃ÷Ò»¸ö¶ÔÏ󣬵«Ëüʲô¶¼Ã»ÓÐ
var life = {};
//ÈÎ ......