È«ÃæÀí½âjavascriptµÄcaller,callee,call,apply¸ÅÄî
Arguments
¸Ã¶ÔÏó´ú±íÕýÔÚÖ´Ðеĺ¯ÊýºÍµ÷ÓÃËüµÄº¯ÊýµÄ²ÎÊý¡£
[function.]arguments[n]
²ÎÊý
function £ºÑ¡Ïî¡£µ±Ç°ÕýÔÚÖ´ÐÐµÄ Function ¶ÔÏóµÄÃû×Ö¡£
n £ºÑ¡Ïî¡£Òª´«µÝ¸ø Function ¶ÔÏóµÄ´Ó0¿ªÊ¼µÄ²ÎÊýÖµË÷Òý¡£
˵Ã÷
ArgumentsÊǽøÐк¯Êýµ÷ÓÃʱ£¬³ýÁËÖ¸¶¨µÄ²ÎÊýÍ⣬»¹ÁíÍâ´´½¨µÄÒ»¸öÒþ²Ø¶ÔÏó¡£ArgumentsÊÇÒ»¸öÀàËÆÊý×鵫²»ÊÇÊý×éµÄ¶ÔÏó£¬ËµËüÀàËÆÊý×éÊÇÒòΪÆä¾ßÓÐÊý×éÒ»ÑùµÄ·ÃÎÊÐÔÖʼ°·½Ê½£¬¿ÉÒÔÓÉarguments[n]À´·ÃÎʶÔÓ¦µÄµ¥¸ö²ÎÊýµÄÖµ£¬²¢ÓµÓÐÊý×鳤¶ÈÊôÐÔlength¡£»¹ÓоÍÊÇarguments¶ÔÏó´æ´¢µÄÊÇʵ¼Ê´«µÝ¸øº¯ÊýµÄ²ÎÊý£¬¶ø²»¾ÖÏÞÓÚº¯ÊýÉùÃ÷Ëù¶¨ÒåµÄ²ÎÊýÁÐ±í£¬¶øÇÒ²»ÄÜÏÔʽ´´½¨ arguments ¶ÔÏó¡£arguments ¶ÔÏóÖ»Óк¯Êý¿ªÊ¼Ê±²Å¿ÉÓá£Ï±ßÀý×ÓÏêϸ˵Ã÷ÁËÕâЩÐÔÖÊ:
callee
//arguments ¶ÔÏóµÄÓ÷¨¡£
function ArgTest(a, b){
var i, s = "The ArgTest function expected ";
var numargs = arguments.length; // »ñÈ¡±»´«µÝ²ÎÊýµÄÊýÖµ¡£
var expargs = ArgTest.length; // »ñÈ¡ÆÚÍû²ÎÊýµÄÊýÖµ¡£
if (expargs < 2)
s += expargs + " argument. ";
else
s += expargs + " arguments. ";
if (numargs < 2)
s += numargs + " was passed.";
else
s += numargs + " were passed.";
s += "\n\n"
for (i =0 ; i < numargs; i++){ // »ñÈ¡²ÎÊýÄÚÈÝ¡£
s += " Arg " + i + " = " + arguments[i] + "\n";
}
return(s); &n
Ïà¹ØÎĵµ£º
ECMAScriptÖУ¬switchÓï¾ä¿ÉÒÔÓÃÓÚ×Ö·û´®£¬¶øÇÒÄÜÓò»Êdz£Á¿µÄֵ˵Ã÷Çé¿ö:
var BLUE="blue" , RED = "red" , GREEN = "green";
switch(sColor)
{
case BLUE: alert("Blue"); break;
&nb ......
±Õ°ü£º
ECMAScriptÖ§³Ö±Õ°ü¡£Ëùν±Õ°ü£¬¾ÍÊǺ¯ÊýÄÜʹÓú¯ÊýÍⶨÒåµÄ±äÁ¿¡£
var iBaseNum = 10;
function addNumbers(iNum1, iNum2)
{
function doAddition()
......
¶¨ÒåºÍÓ÷¨
prompt() ·½·¨ÓÃÓÚÏÔʾ¿ÉÌáʾÓû§½øÐÐÊäÈëµÄ¶Ô»°¿ò¡£
Óï·¨
prompt(text,defaultText)
²ÎÊýÃèÊö
text
¿ÉÑ¡¡£ÒªÔÚ¶Ô»°¿òÖÐÏÔʾµÄ´¿Îı¾£¨¶ø²»ÊÇ HTML ¸ñʽµÄÎı¾£©¡£
defaultText
¿ÉÑ¡¡£Ä¬ÈϵÄÊäÈëÎı¾¡£
˵Ã÷
Èç¹ûÓû§µ¥»÷Ìáʾ¿òµÄÈ¡Ïû°´Å¥£¬Ôò·µ»Ø null¡£Èç¹ûÓû§µ¥»÷È·ÈÏ°´Å¥£¬Ôò·µ»ØÊäÈë×ֶε±Ç°Ï ......
ÎÒÃǶ¼ÖªµÀ£¬ajaxÄÜÌá¸ßÒ³ÃæÔØÈëµÄËٶȵÄÖ÷ÒªÔÒòÊÇͨ¹ýajax¼õÉÙÁËÖظ´Êý¾ÝµÄÔØÈ룬ÕæÕý×öµ½°´Ðè»ñÈ¡£¬¼ÈÈ»Èç´Ë£¬ÎÒÃÇÔÚдajax³ÌÐòµÄʱºò²»·ÁËÍ·ðË͵½Î÷£¬ÔÚ¿Í»§¶ËÔÙ×öÒ»´Î»º´æ,½øÒ»²½Ìá¸ßÊý¾ÝÔØÈëËٶȡ£ÄǾÍÊÇÔÚÔØÈëÊý¾ÝµÄͬʱ½«Êý¾Ý»º´æÔÚä¯ÀÀÆ÷ÄÚ´æÖУ¬Ò»µ©Êý¾Ý±»ÔØÈ룬ֻҪҳÃæδˢУ¬¸ÃÊý¾Ý¾ÍÓÀÔ¶µÄ»º´æÔÚÄÚ´æÖУ¬µ±Ó ......
JavaScript ÊÇÒ»¿îÇ¿´óµÄ¹ã·ºÔËÓÃÓÚÏÖ´úWebÕ¾µã¼°Ó¦ÓõĽű¾ÓïÑÔ¡£×÷Ϊһ¸ö¼¼ÒÕ¾«Õ¿µÄ Web ¿ª·¢Õߣ¬ÕÆÎÕJavaScript¿ÉÒÔÔöÇ¿Óû§µÄʹÓÃÌåÑ飬Ìṩ½»»¥¼°¸»¿Í»§¶ËµÈ¹¦ÄÜ¡£
¾¡¹ÜJavaScript µÄÓï·¨·Ç³£¼òµ¥£¬µ«¶ÔÓÚд³ÌÐò¶øÑÔÈÔÈ»ÊÇÀ§ÄÑÖØÖØ£¬¾ÍÊÇÒòΪËüµÄÔËÐл·¾³£º»ùÓÚWebä¯ÀÀÆ÷¡£
ÒÔÏÂÄú¿ÉÒÔ¿´µ½ÊÕ¼¯µÄ8¸öʵÓÃµÄ JavaScr ......