JavaScript£¨JS£©×Ô´ø×Ö·û´®´¦Àíº¯Êý
concat
½«Á½¸ö»ò¶à¸ö×Ö·ûµÄÎı¾×éºÏÆðÀ´£¬·µ»ØÒ»¸öеÄ×Ö·û´®¡£
var a = "hello";
var b = ",world";
var c = a.concat(b);
alert(c);
//c = "hello,world"
indexOf
·µ»Ø×Ö·û´®ÖÐÒ»¸ö×Ó´®µÚÒ»´¦³öÏÖµÄË÷Òý£¨´Ó×óµ½ÓÒËÑË÷£©¡£Èç¹ûûÓÐÆ¥ÅäÏ·µ»Ø -1 ¡£
var index1 = a.indexOf("l");
//index1 = 2
var index2 = a.indexOf("l",3);
//index2 = 3
charAt
·µ»ØÖ¸¶¨Î»ÖõÄ×Ö·û¡£
var get_char = a.charAt(0);
//get_char = "h"
lastIndexOf
·µ»Ø×Ö·û´®ÖÐÒ»¸ö×Ó´®×îºóÒ»´¦³öÏÖµÄË÷Òý£¨´ÓÓÒµ½×óËÑË÷£©£¬Èç¹ûûÓÐÆ¥ÅäÏ·µ»Ø -1 ¡£
var index1 = lastIndexOf('l');
//index1 = 3
var index2 = lastIndexOf('l',2)
//index2 = 2
match
¼ì²éÒ»¸ö×Ö·û´®Æ¥ÅäÒ»¸öÕýÔò±í´ïʽÄÚÈÝ£¬Èç¹ûôÓÐÆ¥Åä·µ»Ø null¡£
var re = new RegExp(/^\w+$/);
var is_alpha1 = a.match(re);
//is_alpha1 = "hello"
var is_alpha2 = b.match(re);
//is_alpha2 = null
substring
·µ»Ø×Ö·û´®µÄÒ»¸ö×Ó´®£¬´«Èë²ÎÊýÊÇÆðʼλÖúͽáÊøλÖá£
var sub_string1 = a.substring(1);
//sub_string1 = "ello"
var sub_string2 = a.substring(1,4);
//sub_string2 = "ell"
substr
·µ»Ø×Ö·û´®µÄÒ»¸ö×Ó´®£¬´«Èë²ÎÊýÊÇÆðʼλÖúͳ¤¶È
var sub_string1 = a.substr(1);
//sub_string1 = "ello"
var sub_string2 = a.substr(1,4);
//sub_string2 = "ello"
replace
ÓÃÀ´²éÕÒÆ¥ÅäÒ»¸öÕýÔò±í´ïʽµÄ×Ö·û´®£¬È»ºóʹÓÃÐÂ×Ö·û´®´úÌæÆ¥ÅäµÄ×Ö·û´®¡£
var result1 = a.replace(re,"Hello");
//result1 = "Hello"
var result2 = b.replace(re,"Hello");
//result2 = ",world"
search
Ö´ÐÐÒ»¸öÕýÔò±í´ïʽƥÅä²éÕÒ¡£Èç¹û²éÕҳɹ¦£¬·µ»Ø×Ö·û´®ÖÐÆ¥ÅäµÄË÷ÒýÖµ¡£·ñÔò·µ»Ø -1 ¡£
var index1 = a.search(re);
//index1 = 0
var index2 = b.search(re);
//index2 = -1
slice
ÌáÈ¡×Ö·û´®µÄÒ»²¿·Ö£¬²¢·µ»ØÒ»¸öÐÂ×Ö·û´®£¨Óë substring Ïàͬ£©¡£
var sub_string1 = a.slice(1);
//sub_string1 = "ello"
var sub_string2 = a.slice(1,4);
//sub_string2 = "ell"
split
ͨ¹ý½«×Ö·û´®»®·Ö³É×Ó´®£¬½«Ò»¸ö×Ö·û´®×ö³ÉÒ»¸ö×Ö·û´®Êý×é¡£
var arr1 = a.split("");
//arr1 = [h
Ïà¹ØÎĵµ£º
javascript ÊÇÒ»ÖÖÇø·Ö´óСдµÄ³ÌÐòÓïÑÔ.
¶¨ÒåÊý×é:
var strweek= new Array(7);
Îʺűí´ïʽ
var i= (condition)?A:B;
Ï൱ÓÚif-else Óï¾ä;condition ³ÉÁ¢ Ö´ÐÐA £¬²»³ÉÁ¢Ö´ÐÐB;
switch Óï¾ä
var i=3;
var result="";
swithck(i);
{
case 1;
result="First";
case 2;
result="Second";
ca ......
תÔØ:JavaScript»ñÈ¡Ò³Ãæ¿í¶È¸ß¶È´óÈ«
µØÖ·:http://www.cnblogs.com/wcg249165510/archive/2009/02/20/1394749.html
ÍøÒ³¿É¼ûÇøÓò¿í£ºdocument.body.clientWidth
ÍøÒ³¿É¼ûÇøÓò¸ß£ºdocument.body.clientHeight
ÍøÒ³¿É¼ûÇøÓò¿í£ºdocument.body.offsetWidth(°üÀ¨±ßÏߵĿí)
ÍøÒ³¿É¼ûÇøÓò¸ß£ºdocument.body.offsetHeight(° ......
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD id="Head1">
<title>JavaScriptµ÷Óñ¾µØÃüÁî</title>
<script type="text/javascript">
function exec (command)
{
window.oldOnError = window.onerror;
window._command = command;
window. ......
shift£ºÉ¾³ýÔÊý×éµÚÒ»Ï²¢·µ»Øɾ³ýÔªËصÄÖµ£»Èç¹ûÊý×éΪ¿ÕÔò·µ»Øundefined
var a = [1,2,3,4,5];
var b = a.shift(); //a£º[2,3,4,5] b£º1
unshift£º½«²ÎÊýÌí¼Óµ½ÔÊý×鿪ͷ£¬²¢·µ»ØÊý×éµÄ³¤¶È
var a = [1,2,3,4,5];
var b = a.unshift(-2,-1); //a£º[-2,-1,1,2,3,4,5] b£º7
×¢£ºÔÚIE6.0ϲâÊÔ·µ»ØÖµ ......
http://203.208.39.132/search?q=cache:CS7gmmmKO1UJ:cdivilly.wordpress.com/2008/09/05/debugging-javascript-on-internet-explorer-mobile/+mobile+ie+debug&cd=2&hl=zh-CN&ct=clnk&gl=cn&client=firefox-a&st_usg=ALhdy2_5z6wqB0HLfTGoC9EDfEwpnra-LQ ......