È«ÃæÀí½â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
Ïà¹ØÎĵµ£º
javascript³õѧÕß
——È«Ãæѧϰ¶ÔÏó¸ÅÄî
±¾ÎĽéÉÜÁ˼¸ºõËùÓйØÓÚ¶ÔÏóµÄ»ù±¾¸ÅÄʲôÊǶÔÏó£¬ÈçºÎ´´½¨¶ÔÏ󣬶ÔÏóµÄÊôÐÔµÄÉèÖúͶÁÈ¡£¬É¾³ýÊôÐԵķ½·¨£¬¹¹Ô캯Êý£¬¶ÔÏóÔÐÍ£¬¸¸À࣬×ÓÀ࣬¼Ì³ÐµÈµÈ¡£
1.¶ÔÏó
* ¶ÔÏóÊÇÒ»ÖÖ¸´ºÏÊý¾ÝÀàÐÍ£¬ËüÃǽ«¶à¸öÊý¾ÝÖµ¼¯ÖÐÔÚÒ»¸öµ¥ÔªÖУ¬¶øÇÒÔËÐÐʹÓÃÃû×ÖÀ´´æÈ¡ÕâЩֵ¡£½âÊ ......
label:statement
Àý£º
start:var iCount = 10;
±êÇ©¿ÉÒÔ±»ºóÀ´µÄbreakÓï¾ä»òcontinueÓï¾äÒýÓá£
Àý£º
var iNum=0;
outermost:
&n ......
º¯Êý
¼´Ê¹º¯ÊýȷʵÓзµ»ØÖµ£¬Ò²²»±ØÃ÷È·µØÉùÃ÷Ëü¡£¸Ãº¯ÊýÖ»ÐèҪʹÓÃreturnÔËËã·ûºó¸úÒª·µ»ØµÄÖµ¼´¿É¡£
Àý£º
function sum(iNum1, iNum2)
{
  ......
±Õ°ü£º
ECMAScriptÖ§³Ö±Õ°ü¡£Ëùν±Õ°ü£¬¾ÍÊǺ¯ÊýÄÜʹÓú¯ÊýÍⶨÒåµÄ±äÁ¿¡£
var iBaseNum = 10;
function addNumbers(iNum1, iNum2)
{
function doAddition()
......
<script language="javascript">
function ShowTableRow(id)
{
var _Row = document.getElementById(id) <!-- »ñÈ¡IDΪTableRowID µÄ¶ÔÏó -->
var _Img = document.getElementById("Img"+id)
&nb ......