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

[JavaScript]ÀàÖ®Èý


Ïê½âjavascriptÀà¼Ì³Ð»úÖƵÄÔ­Àí
Ä¿Ç° javascriptµÄʵÏּ̳з½Ê½²¢²»ÊÇͨ¹ý“extend”¹Ø¼ü×ÖÀ´ÊµÏֵģ¬¶øÊÇͨ¹ýconstructor functionºÍprototypeÊôÐÔÀ´ÊµÏּ̳С£Ê×ÏÈÎÒÃÇ´´½¨Ò»¸öanimalÀà
js ´úÂë
 
 var animal = function(){  //Õâ¾ÍÊÇconstructor function ÁË 
   this.name = 'pipi';    
   this.age = 10;      
   this.height = 0;      
}      
 //½¨Á¢Ò»¸ö¶¯ÎïµÄʵÀý    
 var a1 =  new animal ();   
¹¹Ô캯ÊýÓëÆäËûÆÕͨº¯ÊýÇø±ðÔÚÓÚ£¬1.¹¹Ô캯ÊýÀïÓÐ this¹Ø¼ü×Ö£¬2.µ÷Óù¹Ô캯ÊýÊÇʹÓõÄnew¹Ø¼ü×Ö¡£Í¨¹ýnewÔËËã·ûµ÷Óù¹Ô캯Êýanimal ºó£¬ÏµÍ³¾Í»á·µ»ØÒ»¸ö¶ÔÏó£¬Õâ¸ö¶ÔÏó¾ÍÏ൱ÓÚ
µÈͬÕâÑùµÄ·½Ê½À´²úÉújs¶ÔÏó¡£
µ½ÕâÀïÎÒÃÇÖªµÀÈçºÎÔÚjsÖж¨ÒåÒ»¸öÀàÁË£¬½ÓÏÂÀ´ÎÒÃÇչʾÈçºÎдһ¸öcat
js ´úÂë
var a1 = { name:'pipi' ,age:10,height:0 }  
  
//»òÕß  
var a1 = new Object();  
a1.name='pipi';  
a1.age = 10;  
a1.height = 0; 
 
js ´úÂë
 
var cat = function(){    
this.play = function(){     
 alert('cat play')    
 }    
 }    
 cat .prototype = new animal ();    
 //prototype ÊôÐÔÖ¸ÏòÒ»¸ö¶ÔÏó 
var c1 = new cat();
µ½ÕâÀcat¾Í¼Ì³ÐÁËanimal ¶ÔÏó£¬ÀàcatµÄÒ»¸öʵÀý¶ÔÏóc1ÓµÓÐÊôÐÔname,age,height,ºÍ·½·¨playÁË¡£
ÄÇôprototypeÆðµ½ÁËÒ»¸öʲôÑùµÄ×÷ÓÃÄØ£¿
prototype¾ÍºÃ±ÈÒ»¸öÖ¸Õ룬ËüÖ¸ÏòÒ»¸öobject£¬Õâ¸öobject¾Í³ÆΪ×ÓÀà¶ÔÏóµÄÔ­ÐÍ¡£µ±catµÄ¶ÔÏó±»´´½¨µÄʱºò£¬ÓÉÓÚcatµÄ¹¹Ô캯ÊýÓµÓÐprototypeÊôÐÔ£¬ÄÇôcatµÄʵÀý¾Í»á¼ä½ÓÖ¸ÏòÕâ¸öÔ­ÐͶÔ


Ïà¹ØÎĵµ£º

Javascript Ö®apply()

1¡¢¶ÔÏóµÄ¼Ì³Ð£¬Ò»°ãµÄ×ö·¨ÊǸ´ÖÆ£ºObject.extend
prototype.jsµÄʵÏÖ·½Ê½ÊÇ£º
Object.extend = function(destination, source){
for (property in source) {
destination[property] = source[property];
}
return destination;
......

JavaScript isNaN() º¯Êý


·µ»Ø JavaScript È«¾Ö¶ÔÏó²Î¿¼ÊÖ²á
¶¨ÒåºÍÓ÷¨
isNaN() º¯ÊýÓÃÓÚ¼ì²éÆä²ÎÊýÊÇ·ñÊÇ·ÇÊý×ÖÖµ¡£
Óï·¨
isNaN(x)
²ÎÊýÃèÊö
x
±ØÐè¡£Òª¼ì²âµÄÖµ¡£
·µ»ØÖµ
Èç¹û x ÊÇÌØÊâµÄ·ÇÊý×ÖÖµ NaN£¨»òÕßÄܱ»×ª»»ÎªÕâÑùµÄÖµ£©£¬·µ»ØµÄÖµ¾ÍÊÇ true¡£Èç¹û x ÊÇÆäËûÖµ,Ôò·µ»Ø false¡£
˵Ã÷
isNaN() º¯Êý¿ÉÓÃÓÚÅжÏÆä²ÎÊýÊÇ·ñÊÇ NaN£ ......

JavascriptÔÚÒ³Ãæ¼ÓÔØʱµÄÖ´ÐÐ˳Ðò

Ò»¡¢ÔÚHTMLÖÐǶÈëJavasriptµÄ·½·¨
Ö±½ÓÔÚJavascript´úÂë·ÅÔÚ±ê¼Ç¶Ô<script>ºÍ</script>Ö®¼ä
ÓÉ<script />±ê¼ÇµÄsrcÊôÐÔÖƶ¨ÍⲿµÄjsÎļþ
·ÅÔÚʼþ´¦Àí³ÌÐòÖУ¬±ÈÈ磺<p onclick="alert('ÎÒÊÇÓÉonclickʼþÖ´ÐеÄJavascript')">µã»÷ÎÒ</p>
×÷ΪURLµÄÖ÷Ì壬Õâ¸öURLʹÓÃÌØÊâµÄJavascript ......

JavaScriptÈçºÎ¶¯Ì¬µÄÉèÖñí¸ñµÄÑùʽ


¶þ¡¢¶¯Ì¬¸ø±í²åÈëÐУº
function addRow(){
  //¶¯Ì¬²åÈëÒ»ÐÐ
  var oRow1=mediaMes.insertRow(mediaMes.rows.length);
  //ÉèÖÃtrµÄid
  oRow1.id="tr"+thisId;
  //»ñµÃ±í×ܵÄÐÐÊý
  var aRows=mediaMes.rows;
  //»ñµÃÐÂÌí¼ÓÐеÄÁм¯ºÏ
  var aCells=oRow1. ......

¹ØÓÚjavascript ÄäÃûº¯ÊýµÄµ÷Ó÷½Ê½

½ñÌì¿´jQueryµÄʱºò·¢ÏÖµÄÊéдÐÎʽԭÀ´Ã»Óмû¹ý ÈçÏ£º
(function(){
statement
...
})();
²»Àí½â£¬ºóÀ´ÉÏÍø²éÁËһϣ¬Ô­À´ÊÇjavascriptÄäÃûº¯ÊýµÄµ÷Ó÷½Ê½
 http://zhidao.baidu.com/question/95789340.html
javascript ¿ÉÒÔÒÔÏ·½Ê½µ÷Óú¯Êý
ÉùÃ÷
a = function(){};
µ÷ÓÃ
a();
¿ÉÒÔÀí½âΪ
(function(){ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ