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

javascriptÕýÔò±í´ïʽʵÏÖtrim()ÒÉ»ó

ÕýÔÚ¿´¡¡javascript¸ß¼¶³ÌÐòÉè¼Æ¡¡,ÆäÖйØÓÚ·Ö×éÀïÃæµÄÒ»¾ä´úÂë²»ÊÇÌ«Àí½â:
ͨ¹ýÅäºÏʹÓÃString¶ÔÏóµÄreplace()·½·¨¼°·´ÏòÒýÓ㬾ͿÉÒÔ¶¨Òå×Ô¼ºµÄtrim()·½·¨:
String.prototype.trim = function() {
var reExtraSpace = /^\s+(.*?)\s+$/;
return this.replace(reExtraSpace,"$1");
}
 
Ò»¿ªÊ¼ÔõôҲ²»Àí½â trim() ·½·¨ÊÇÔõôÆð×÷ÓõÄ
var sTest = " this is a test ";
alert("[" + sTest + "]"); //outputs " [ this is a test ] "
alert("[" + sTest.trim() + "]"); outputs " [this is a test] " 
ºóÀ´²éÁËһϡ¡javascript ÀïÃæ StringObject µÄ replace(regexp,replacement)
·½·¨µÄµÚ¶þ¸ö²ÎÊýreplacementÀïÃæµÄ"$"ÌØÊ⺬Ò壺
$n±íʾµÚ n ¸ö×Ó±í´ïʽ , Ò²¾ÍÊÇ .*?
Ô­À´·Ö×é¾ÍÊÇÕýÔò±í´ïʽµÄ×Ó±í´ïʽ


Ïà¹ØÎĵµ£º

String.prototypeʵÏÖµÄһЩjavascriptº¯Êý


//String.prototypeʹÓà   
  
//ÅúÁ¿Ìæ»»£¬±ÈÈ磺str.ReplaceAll([/a/g,/b/g,/c/g],["aaa","bbb","ccc"])   
String.prototype.ReplaceAll=function (A,B) {   
    var C=this;   
    for(var i ......

JavaScriptµÄwithÓï¾ä


withÓï¾ä
    ÓÃÓÚÉèÖôúÂëÌض¨¶ÔÏóµÄ×÷ÓÃÓò¡£
    Àý£º
        var sMessage = "hello world";
        with(sMessage)
        {
         &nbs ......

¹ØÓÚJavaScriptÖеÄprompt·½·¨


¶¨ÒåºÍÓ÷¨
prompt() ·½·¨ÓÃÓÚÏÔʾ¿ÉÌáʾÓû§½øÐÐÊäÈëµÄ¶Ô»°¿ò¡£
Óï·¨
prompt(text,defaultText)
²ÎÊýÃèÊö
text
¿ÉÑ¡¡£ÒªÔÚ¶Ô»°¿òÖÐÏÔʾµÄ´¿Îı¾£¨¶ø²»ÊÇ HTML ¸ñʽµÄÎı¾£©¡£
defaultText
¿ÉÑ¡¡£Ä¬ÈϵÄÊäÈëÎı¾¡£
˵Ã÷
Èç¹ûÓû§µ¥»÷Ìáʾ¿òµÄÈ¡Ïû°´Å¥£¬Ôò·µ»Ø null¡£Èç¹ûÓû§µ¥»÷È·ÈÏ°´Å¥£¬Ôò·µ»ØÊäÈë×ֶε±Ç°Ï ......

Àí½âjavascriptÖÐarguments,callee,caller


<!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" lang="gb2312"> 
<head> 
<head> 
<title> ¹ØÓÚarguments,callee,callerµÈµÄ²âÊÔ &l ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ