JavascriptÊý×é¼°Æä²Ù×÷
±¾ÎĽéÉÜÈçϼ¸¸ö·½ÃæµÄÄÚÈÝ:
1.ÈçºÎ´´½¨Êý×é
2.ÈçºÎ¶ÔÊý×é½øÐвÙ×÷£¨Ìí¼Ó,ɾ³ý,¶ÁÈ¡)
3.Êý×é³£¼û·½·¨ºÍÊôÐÔ
ÈçºÎ´´½¨Ò»¸öÊý×é,Ò»°ãµØ¸ù¾Ý³õʼ»¯É趨¼òµ¥·ÖΪ3ÖÖ:
1.µ¥´¿´´½¨Êý×é:
var arr=new Array();
Òªµã:ÓÃnew¹Ø¼ü×Ö´´½¨Êý×é¶ÔÏóArray(),Array()¶ÔÏóÊÇÒ»¸ö±¾µØÀà,¿ÉÒÔÓÃnew´´½¨Ò»¸ö¶ÔÏóºóʹÓÃ
2.´´½¨Êý×éµÄͬʱ¹æ¶¨Êý×é´óС:
var arr=new Array(10);//ÕâÀï¾Í´´½¨ÁËÒ»¸ö³õʼ»¯´óСΪ10µÄÊý×é
×¢Òâ:µ±Ê¹ÓÃÊý×é´óС²Ù×÷³õʼ»¯´óСʱ,Êý×é»á×Ô¶¯±»³Å´ó,²»»áÏñCÓïÑÔÄÇÑù·¢Éú´íÎó.¶¯Ì¬Ôö³¤ÊÇjsÊý×éµÄÒ»¸öÐÔÖÊ.ÁíÍâ,jsÖÐÖ§³Ö×î´óÊý×鳤¶ÈΪ
4294967295
3.Ö±½Ó³õʼ»¯:
var arr=new Array("love","hate","pain");//ÕâÀï¾ÍÖ±½Ó³õʼ»¯ÁËÊý×é
»òvar arr=["happy","cute","scare"];//À¨ºÅÒ²¿ÉÒÔÉùÃ÷Ò»¸öÊý×é¶ÔÏó
µ±È»,ÀàËÆCÓïÑÔ,¿ÉÒÔ¶¨Òå2ά3άºÍ¶àάµÄÊý×é,ÀýÈç:
<script language="javascript">
var myArray = new Array();
for(var i=0;i<10;i++ )...{
myArray[i]=new Array();
myArray[i][0]=Math.floor(Math.random()*10);
myArray[i][1]=Math.floor(Math.random()*10);
myArray[i][2]=Math.floor(Math.random()*10);
myArray[i][3]=Math.floor(Math.random()*10);
myArray[i][4]=Math.floor(Math.random()*10);
myArray[i][5]=Math.floor(Math.random()*10);
myArray[i][6]=Math.floor(Math.random()*10);
myArray[i][7]=Math.floor(Math.random()*10);
myArray[i][8]=Math.floor(Math.random()*10);
}
myArray.sort( function(x, y) ...{
return (x[0]==y[0])?((x[4]==y[4])?(x[8]-y[8]):(x[4]-y[4])):(x[2]-y[2])
});
for(var i=0;i<myArray.length
Ïà¹ØÎĵµ£º
ÔÚ±¾ÕÂÖУ¬ÎÒÃǽ«·ÖÎöDouglas Crockford¹ØÓÚJavaScript¼Ì³ÐµÄÒ»¸öʵÏÖ
CrockfordÊÇJavaScript¿ª·¢ÉçÇø×îÖªÃûµÄȨÍþ£¬ÊÇJSON
¡¢JSLint
¡¢JSMin
ºÍADSafe
Ö®¸¸£¬ÊÇ¡¶JavaScript: The Good Parts¡·µÄ×÷Õß¡£
ÏÖÔÚÊÇYahooµÄ×ÊÉîJavaScript¼Ü¹¹Ê¦£¬²ÎÓëYUIµÄÉè¼Æ¿ª·¢¡£ ÕâÀïÓÐһƪÎÄÕÂ
Ïêϸ½éÉÜÁËCrockfordµÄÉúƽºÍÖø×÷¡£ ......
<!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> new document </title>
<meta name="generator" content="edit ......
×î½ü×öË°Îñ×ÛºÏƽ̨¹¤×÷Á÷£¬ ÔÚÒ³ÃæÉÏÅжÏÊÇ·ñÊÇ“»õ±Ò½ð¶î”¸ñʽ£¬Ê¹ÓõÄÊÇÕýÔò±í´ïʽ£¬Ò»Ö±¶¼Ã»ÓÐÎÊÌ⣬
ºóÀ´Í»È»ÎÞ·¨ÑéÖ¤£¬ ¾ÍÊDz»·ûºÏÕýÔò±í´ïʽµÄ½á¹¹£¬×îºóÖÕÓÚ·¢ÏÖ ½ð¶îºóÃæ°üº¬¿Õ¸ñ×Ö·û´®£¬ÔÚÍøÉÏÕÒµ½Ò»¶Î´úÂë £¬ÕýºÃ½â¾ö¡£
String.prototype.trim= function(){
// ÓÃÕýÔò±í´ïʽ½«Ç°ºó¿ ......
JavascriptË¢ÐÂÒ³ÃæµÄ¼¸ÖÖ·½·¨£º
³ÌÐò´úÂë
1 history.go(0)
2 location.reload()
3 location=location
4 location.assign(location)
5 document.execCommand('Refres ......
½ñÌìÔÚ²©¿ÍÔ°ÉÏ¿´µ½Ò»ÆªÎÄÕ£¬¸ú×ÅѧϰÁËһϣ¬×ª¹ýÀ´Óë´ó¼Ò·ÖÏí£¬²¿·ÖÄÚÈÝÎÒ×öÁ˲¹³ä£¡
Ò»¡¢JavaScriptÕýÔò±í´ïʽ»ù±¾ÖªÊ¶
1¡¢JavaScriptÕýÔò±í´ïʽ´´½¨ºÍÓ÷¨
ÉùÃ÷ÕýÔò±í´ïʽÓÐÁ½ÖÖ·½Ê½£º
a) var reCat = new RegExp("cat");
b) var reCat = /cat/; //perl·ç¸ñ£¨ÍƼö£©& ......