JavaScriptµÄ5ÖÖÊý¾ÝÀàÐÍ
JavaScriptÒÔECMAScript±ê×¼×÷Ϊ¹¦ÄÜ»ù×¼£¬ECMAScriptÓÐ5ÖÖÔÐÍÀàÐÍ£ºUndefined£¬Null£¬Boolean£¬NumberºÍString¡£
¿ÉÒÔÓÃtypeofÀ´ÅжÏÀàÐÍ£¬Àý£º
var sTemp = "test string";
alert(typeof sTemp);
alert(typeof 95);
·µ»ØÏÂÁÐÖµ£º
"undefined",Èç¹û±äÁ¿ÊÇUndefinedÀàÐÍ
"boolean",Èç¹ûÊÇBooleanÀàÐÍ
"number",Èç¹ûÊÇNumberÀàÐÍ
"string",Èç¹ûÊÇStringÀàÐÍ
"object",Èç¹ûÊÇÒ»ÖÖÒýÓÃÀàÐÍ»òNullÀàÐÍ¡£null±»ÈÏΪÊǶÔÏóµÄռλ·û¡£
undefinedÀàÐÍ£º
µ±ÉùÃ÷±äÁ¿Î´³õʼ»¯Ê±£¬±äÁ¿µÄĬÈÏÖµÊÇundefined¡£undefined²»Í¬ÓÚ䶨Ò壬µ«typeof²»Çø·Ö£¬Àý£º
var oTemp ;
alert(typeof oTemp); //Êä³öundefined
alert(typeof oTemp1); // Êä³öundefined
µ±ÆäËûÔËËã·ûÇø·Ö£¬Àý£º
var oTemp;
alert(oTemp == undefined); // Êä³ötrue
alert(oTemp1 == undefined); // error
º¯ÊýÎÞ·µ»ØÖµÊ±£¬·µ»ØÖµÒ²ÊÇundefined
NullÀàÐÍ£º
NullÀàÐÍÖ»ÓÐÒ»¸öרÓÃÖµnull¡£Öµundefinedʵ¼ÊÉÏÊÇ´ÓnullÅÉÉúµÄ£¬ËùÒÔECMAScript°ÑËûÃǶ¨ÒåΪÏàµÈ£¬¼´£ºalert(null == undefined) Êä³ötrue¡£
ËäÈ»ËûÃÇÏàµÈµ«ÒâÒ岻ͬ£¬nullÓÃÓÚ±íʾÉÐδ´æÔڵĶÔÏó¡£
BooleanÀàÐÍ£º
false²»µÈÓÚ0£¬µ«0¿ÉÒÔת»»Îªfalse¡£
NumberÀàÐÍ£º
°Ë½øÖÆÊ×Êý×Ö±ØÐëÊÇ0£¬È磺070£»Ê®Á
Ïà¹ØÎĵµ£º
//¹ýÂËÁ½¶ËµÄ¿Õ¸ñ
function trim(str){
return str.replace(/(^\s*)|(\s*$)/g, "");
}
//¹ýÂË×ó±ßµÄ¿Õ¸ñ
function ltrim(str){
return  ......
ÔÚ document ¶ÔÏóÖÐÓÐÒ»¸ö cookie ÊôÐÔ¡£µ«ÊÇ Cookie ÓÖÊÇʲô£¿“ijЩ Web Õ¾µãÔÚÄúµÄÓ²ÅÌÉÏÓúÜСµÄÎı¾Îļþ´æ´¢ÁËһЩÐÅÏ¢£¬ÕâЩÎļþ¾Í³ÆÎª Cookie¡£”—— MSIE °ïÖú¡£Ò»°ãÀ´Ëµ£¬Cookies ÊÇ CGI »òÀàËÆ£¬±È HTML ¸ß¼¶µÄÎļþ¡¢³ÌÐòµÈ´´½¨µÄ£¬µ«ÊÇ JavaScript Ò²ÌṩÁË¶Ô Cookies µÄºÜÈ«ÃæµÄ·ÃÎÊȨÀû ......
js eval
evalº¯Êý½ÓÊÕÒ»¸ö²ÎÊýs£¬Èç¹ûs²»ÊÇ×Ö·û´®£¬ÔòÖ±½Ó·µ»Øs¡£·ñÔòÖ´ÐÐsÓï¾ä¡£Èç¹ûsÓï¾äÖ´Ðнá¹ûÊÇÒ»¸öÖµ£¬Ôò·µ»Ø´ËÖµ£¬·ñÔò·µ»Øundefined¡£
Àý×Ó
Ö±½ÓÔËËã
alert(eval('1+2')); // ->3
¸³Öµ
eval('var aa = 5');
alert(aa); // ->5
ÀàÐÍת»»
var yy = "{a:'aa',b:'bb'}";
yy = eval('(' + yy + ')');
......
Ã²ËÆCSDNÀïµÄ¶¼ÊÇרҵÈËÊ¿£¬¸ßÊÖ¿ÉÒÔÂÓ¹ýÁË£¬ºÇºÇ¡£
Ò»ÏÂÊÇÔ´Â룺
<!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>
<meta http-equiv="Content-Type" content ......
//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 ......