Ò׽ؽØÍ¼Èí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

JavaScriptʵÏÖÀàµÄ¼Ì³Ð

ÔÚJavaScriptÖÐûÓÐרÃŵĻúÖÆÀ´ÊµÏÖÀàµÄ¼Ì³Ð£¬µ«ÊÇ¿ÉÒÔͨ¹ý¿½±´Ò»¸öÀàµÄprototypeµ½ÁíÍâÒ»¸öÀàÀ´ÊµÏּ̳У¬Ò»ÖÖ¼òµ¥µÄʵÏÖÈçÏ£º
function class1(){
}
function class2(){
}
class2.prototype=class1.prototype;
class2.prototype.moreProperty="xxx";
class2.prototype.moreMethod1=function(){
}
var obj = new class2();
ÕâÑù£¬Ê×ÏÈÊÇclass2ºÍclass1¾ßÓÐÒ»ÑùµÄprototype£¬²»¿¼Âǹ¹Ô캯Êý£¬Á½¸öÀàÊǵȼ۵ģ¬Ëæºó£¬ÓÖͨ¹ýprototype¸øclass2¸³ÓèÁËÁ½¸ö¶îÍâµÄ·½·¨£¬ËùÒÔclass2ÊÇÔÚclass1µÄ»ù´¡ÉÏÔö¼ÓÁËÊôÐԺͷ½·¨£¬Õâ¾ÍʵÏÖÁËÀàµÄ¼Ì³Ð¡£
JavaScriptÌṩinstanceof²Ù×÷·ûÀ´ÅжÏÒ»¸ö¶ÔÏóÊÇ·ñÊÇij¸öÀàµÄʵÀý£¬¶ÔÓÚÉÏÃæ½¨Á¢µÄobj¶ÔÏó£¬ÏÂÃæÁ½ÌõÓï¾ä¶¼ÎªÕ棺
obj instanceof class1
obj instanceof class2
instanceofµÄ²Ù×÷»úÖÆ£¬ÊµÖÊÉϾÍÊÇÅжÏÒ»¸ö¶ÔÏóÊÇ·ñÊÇÒ»¸öprototypeµÄʵÀý¡£
ÀûÓ÷´Éä»úÖÆºÍprototypeʵÏּ̳Уº
ÉÏÃæ½éÉܵÄprototypeʵÏֵļ̳У¬²»ÊǺܺõÄÒ»ÖÖ·½·¨£¬±Ï¾¹Á½¸öÀ๲ÏíÒ»¸öprototype£¬ÈκζԳÉÔ±µÄÖØÐ¶¨Òå¶¼»áÏ໥ӰÏ죬²»ÊÇÑϸñÒâÒåÉϵļ̳С£µ«ÔÚÕâ¸ö˼ÏëÉÏ¿ÉÒÔ·´Éä»úÖÆÀ´ÊµÏÖÀàµÄ¼Ì³Ð£¬Ë¼Â·ÈçÏ£º
ÀûÓÃfor(...in...)Óï¾äö¾Ù³öËùÓлùÀàprototypeµÄ³ÉÔ±£¬²¢½«Æä¸³Öµ¸ø×ÓÀàµÄprototype¶ÔÏó£¬È磺
function class1(){
}
class1.prototype={
         method:function(){
                  alert(1);
};
         method2:function(){
                  alert("method2");
}
}
function class2(){
}
for(var p in class1.prototype){
            class2.prototype[p]=class1.prototype[p];
}
//¸²¸Ç¶¨Òåclass1ÖеÄmethod·½·¨
class2.prototype.method={
                    alert(2);
}
var obj1=new class1();
var obj2=new class2();
obj1.method();
obj2.method();
obj1.method2();
obj2.mentod2();
obj2ÖÐÖØ¸´¶¨ÒåµÄmethodÒѾ­¸²¸ÇÁ˼̳еÄmethod·½·


Ïà¹ØÎĵµ£º

javascript£º°´»Ø³µÏàÓ¦°´Å¥Ìύʼþ

    ÔÚ±íµ¥Ìύǰ¾­³£Óöµ½±íµ¥ÑéÖ¤ÎÊÌâ¶ø³£Óõķ½·¨ÓÐÒÔÏÂÁ½ÖÖ£º
    1¡¢Ê¹ÓÃÌá½»°´Å¥Ìá½»£¬ÔÚform±íµ¥ÖеÄonsubmitʼþ½øÐÐ±íµ¥ÑéÖ¤£º
        <script type="text/javascript">
        & ......

javascript ²Ù×÷ÈÕÆÚ ²âÊÔ(×¢Òâä¯ÀÀÆ÷¼æÈÝÎÊÌ⣩

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>javas
cript ²Ù×÷ÈÕÆÚ ²âÊÔ</title>
<meta http-equiv= ......

[´ÓjQuery¿´JavaScript]

 jQueryƬ¶Î£º
(function(){
//ÕâÀïºöÂÔjQueryËùÓÐʵÏÖ
})();
¡¡¡¡°ëÄêǰ³õ´Î½Ó´¥jQueryµÄʱºò£¬ÎÒÒ²ÏñÆäËûÈËÒ»ÑùºÜÐ˷ܵØÏë¿´¿´Ô´ÂëÊÇʲôÑùµÄ¡£È»¶ø£¬ÔÚ¿´µ½Ô´ÂëµÄµÚÒ»ÑÛ£¬ÎÒ¾ÍÃÔºýÁË¡£ÎªÊ²Ã´Ö»ÓÐÒ»¸öÄäÃûº¯ÊýÓÖû¿´µ½ÔËÐУ¨µ±È»ÊÇÔËÐÐÁË……£©£¬¾ÍÄÜÓÐjQueryÕâô¸öº¯Êý¿âÁË£¿ÓÚÊÇ£¬ÎÒ±§×ÅÒÉÎÊÀ´µ½ ......

javascript typeofµÄÓ÷¨

  ÔÚjsÀïÓõ½Êý×é,±ÈÈç ¶à¸öÃû×ÖÏàͬµÄinput, ÈôÊǶ¯Ì¬Éú³ÉµÄ, Ìύʱ¾ÍÐèÒªÅÐ¶ÏÆäÊÇ·ñÊÇÊý×é.
if(document.mylist.length != "undefined" ) {} Õâ¸öÓ÷¨ÓÐÎó.
ÕýÈ·µÄÊÇ if( typeof(document.mylist.length) != "undefined" ) {}
»ò if( !isNaN(document.mylist.length) ) {}
typeofµÄÔËËãÊý䶨Òå,·µ»ØµÄ¾ÍÊÇ "un ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ