JavaScriptÌØÐÔ×ܽá
1.js²»Ö§³ÖÖØÔØ£¬ÒòΪjsÀïµÄº¯Êý¶¼ÊÇÒ»¸ö¶ÔÏó£¬jsÀïÓиöÒþº¬¶ÔÏóFunction,ËùÓеÄjsº¯Êý¶¼ÊÇÒ»¸öFunctionÀàÐ͵ĶÔÏó¡£±ÈÈ磺
Java´úÂë
function add(number)
{
alert("hello");
}
function add(number)
{
alert("hello");
}
µÈ¼ÛÓÚ
Java´úÂë
var add = new Function("number","alert('hello');");
var add = new Function("number","alert('hello');");
ÓÉÓÚjsÀïÿһ¸öº¯ÊýÀï¶¼Òþº¬Ò»¸ö¶ÔÏó½Ðarguments,¸ÃargumentsÊÇÒ»¸öÊý×飬ͨ¹ýarguments¿ÉÒÔ»ñµÃµ½Êµ¼Ê´«µÝ²ÎÊýµÄ¸öÊý(arguments.length)¼°Êµ¼Ê´«µÝ²ÎÊýµÄÖµ(arguments[0],arguments[1]...)
ËùÒÔ¿ÉÒÔͨ¹ýarguments¶ÔÏóÀ´Ä£ÄâÖØÔØ£¬ÈçÏ£º
Java´úÂë
function add()
{
if(arguments.length == 1)
{
alert(arguments[0] + 10);
}
if(arguments.length == 2)
{
alert(arguments[0] + arguments[1] + 10);
}
}
}
add(5);
add(5,1);
function add()
{
if(arguments.length == 1)
{
alert(arguments[0] + 10);
}
if(arguments.length == 2)
{
alert(arguments[0] + arguments[1] + 10);
}
}
}
add(5);
add(5,1);
2.ÿ¸öº¯ÊýµÄÃû×Ö¶¼ÓÐÒ»¸öÊôÐÔ½Ðlength,“ÊôÐÔÃû.length ”»ñµÃ¸Ãº¯ÊýÄܽÓÊܲÎÊýµÄ¸öÊý¡£
È磺
Java´úÂë
function a1()
{
}
function a2(number)
{
}
 
Ïà¹ØÎĵµ£º
×ֺţº´ó ÖРС
·½·¨Ò»£º×µÄ£¬×îÈÝÒ×Àí½âµÄ£¬ÇÒ¿ÉÒÔËæÒâÉèÖÃÒªÅųýµÄ×Ö·û
<script language="javascript">
function isChinese1(str){
var badChar ="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
badChar += "abcdefghijklmnopqrstuvwxyz";
badChar += "0123456789";
badChar += " "+"¡¡";//°ë½ÇÓëÈ«½Ç¿Õ¸ñ
badChar ......
replace()×î¼òµ¥µÄËãÊÇÄÜÁ¦¾ÍÊǼòµ¥µÄ×Ö·ûÌæ»»¡£
ʾÀý´úÂëÈçÏ£º
<script language="javascript">
var strM = "javascript is a good script language";
//ÔÚ´ËÎÒÏ뽫×ÖĸaÌæ»»³É×ÖĸA
alert(strM.replace("a","A"));
</script>
ËüÖ»Ìæ»»ÁËÊ××Öĸ¡£µ«Èç ......
scrollHeight: »ñÈ¡¶ÔÏóµÄ¹ö¶¯¸ß¶È¡£
scrollLeft:ÉèÖûò»ñȡλÓÚ¶ÔÏó×ó±ß½çºÍ´°¿ÚÖÐĿǰ¿É¼ûÄÚÈݵÄ×î×ó¶ËÖ®¼äµÄ¾àÀë
scrollTop:ÉèÖûò»ñȡλÓÚ¶ÔÏó×î¶¥¶ËºÍ´°¿ÚÖпɼûÄÚÈݵÄ×î¶¥¶ËÖ®¼äµÄ¾àÀë
scrollWidth:»ñÈ¡¶ÔÏóµÄ¹ö¶¯¿í¶È
offsetHeight:»ñÈ¡¶ÔÏóÏà¶ÔÓÚ°æÃæ»òÓɸ¸×ø±ê offsetParent ÊôÐÔÖ¸¶¨µÄ¸¸×ø±êµÄ¸ß¶È
offsetL ......
1£¬¶ÔÏóµÄ¹¹³É
¶ÔÏóÓÐÌØÐÔ¹¹³É(attribute)£¬¿ÉÒÔÊÇÔʼֵ£¬Ò²¿ÉÒÔÊÇÒýÓÃÖµ¡£Èç¹ûÌØÐÔ´æ·ÅµÄÊǺ¯Êý£¬Ëü½«±»¿´×ö¶ÔÏóµÄ·½·¨£¨method£©£¬·ñÔò¸ÃÌØÐÔ±»¿´×öÊôÐÔ£¨property£©¡£
2£¬¶¨ÒåÀà»ò¶ÔÏó
£¨1£©¹¤³§·½Ê½
Code
function createCar(sColor,iDoors) {
&nb ......
Ëæ×Å»¥ÁªÍøµÄ·ÉËÙ·¢Õ¹£¬µØÇò±äµÃÔ½À´Ô½Ð¡£¬ÈËÃÇ¿ÉÒÔ¿çԽʱ¼äºÍ¿Õ¼äµÃ½çÏÞ½øÐн»Á÷ÓÚºÏ×÷¡£µ«ÊÇËæÖ®Ò²²úÉúÁËһЩËÁÒâ¸ãÆÆ»µµÄºÚ¿Í£¬Õâ¾ÍʹµÃ³ÌÐòÉè¼ÆÈËÔ±ÔÚ±àÖÆÓ¦ÓóÌÐòÖÐÒª¿¼Âǵ½ºÚ¿ÍÏ®»÷Õâ¸öÎÊÌ⣬ËùÒÔ×ÔÈ»¶øÈ»µØ¾Í»áÏëµ½±£»¤¡£±¾½Ú½Ì³Ì½«½ÌÄãÔõÑùÀûÓÃjavascript½øÐÐÃÜÂë±£»¤¡£ÀûÓà JavaScriptÀ´¶ÔÍøÒ³½øÐÐÃÜÂë±£»¤Óм¸ÖÖ· ......