javascript之Arguments
一、Arguments.callee //获取当前正在执行的函数,也就是这个函数自身,常用于获取匿名函数自身
语法:arguments.callee

var factorial = function (x) {
if (x < 2) {
return 1;
}
else {
return x * arguments.callee(x - 1);
}
}
document.write(factorial(3)); //返回6 3*2*1

二、Arguments.length //获取传递给函数的参数个数
语法:arguments.length

var fun1 = function (x) {
return arguments.length;
}
var fun2 = function (x,y) {
return arguments.callee.length;
}
document.write(fun1(3, 2, 1)); //返回3,一共传入了3个参数。
document.write("<br/>" + fun2()); //返回2,函数期待的参数个数。

三、Argument[] //按索引获取参数,索引从0开始
语法:arguments[index]
var fun1 = function (x,y) {
document.write(arguments[0]); //输出1,索引为0就x,也就是本例中的1
document.write("<br/>" + arguments[1]); //输出2,索引为1就是y,也就是本例中的2
}
fun1(1,2);
javascript之Arguments的更多相关文章
- JavaScript之arguments对象讲解
javascript的arguments对象类似于PHP的extract()函数实现. 在不确定函数参数个数的情况下,可以通过arguments访问参数,并以索引0为起始. function sayH ...
- javascript 中 arguments.callee属性
javascript 中 arguments.callee属性 可以在函数内部,指向的是这个函数(或者叫做“类”)本身. 相当于PHP 中的 self 关键字. The arguments.calle ...
- [译]Javascript 参数(arguments)对象
本文翻译youtube上的up主kudvenkat的javascript tutorial播放单 源地址在此: https://www.youtube.com/watch?v=PMsVM7rjupU& ...
- 2015第37周五javascript函数arguments对象巧用一
Javascript函数的一个巧妙利用:假定action中有一个JSONObject类型的对象data,其值有可能为空,则前台JSP页面的JS代码中想直接通过EL表达式,即${data}的形式访问对象 ...
- javascript 中arguments.callee 调用自身
一.Arguments该对象代表正在执行的函数和调用他的函数的参数.[function.]arguments[n]参数function :选项.当前正在执行的 Function 对象的名字.n :选项 ...
- 【转】JavaScript 之arguments、caller 和 callee 介绍
1.前言 arguments, caller , callee 是什么? 在JavaScript 中有什么样的作用?本篇会对于此做一些基本介绍. 本文转载自:http://blog.csdn.ne ...
- JavaScript 之arguments、caller 和 callee 介绍
1.前言 arguments, caller , callee 是什么? 在javascript 中有什么样的作用?本篇会对于此做一些基本介绍. 2. arguments arguments: ...
- javascript中arguments的应用——不定项传参求和
<script type="text/javascript"> window.onload=function(){ function sum(){ var result ...
- JavaScript之arguments.callee
arguments.callee 在哪一个函数中运行,它就代表哪个函数. 一般用在匿名函数中. 在匿名函数中有时会需要自己调用自己,但是由于是匿名函数,没有名子,无名可调. 这时就可以用argumen ...
随机推荐
- json编解码
[elk@zjtest7-frontend test]$ cat json.conf input { stdin { } } filter { json{ source =>"mess ...
- [Linux] killall 、kill 、pkill 命令详解
killall 命令 Linux系统中的killall命令用于杀死指定名字的进程(kill processes by name).我们可以使用kill命令杀死指定进程PID的进程,如果要找到我们需要杀 ...
- qt绘制设备
# -*- coding: utf-8 -*- # python:2.x __author__ = 'Administrator' from PyQt4.QtGui import * from Py ...
- HDU 1085 Holding Bin-Laden Captive! (母函数)
Holding Bin-Laden Captive! Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Ja ...
- TCP三次握手的过程
三次握手 下图就是wireshark抓包工具抓获的TCP连接建立的三次握手过程: http://www.cnblogs.com/hnrainll/archive/2011/10/14/2212415. ...
- 在Qt中用QAxObject来操作Excel
目录(?)[+] 下一篇:用dumpcpp工具生成的excel.h/excel.cpp来操纵Excel 最近写程序中需要将数据输出保存到Excel文件中.翻看<C++ GUI Pro ...
- iframe框架默认占满整个屏幕
<script language="JavaScript"> if (window != top) { top.location.href = location.hre ...
- 解决数据库Operation not allowed when innodb_forced_recovery > 0
解决数据库Operation not allowed when innodb_forced_recovery > 0 请修改my.cnf innodb_force_recovery = 1 修改 ...
- SOLR使用手册之操作collection
一.Collections API 参考:https://cwiki.apache.org/confluence/display/solr/Collections+API 因为API比较多,我就不一 ...
- Spark RDD设计学习笔记
本文档是学习RDD经典论文<Resilient Distributed Datasets: A Fault-Tolerant Abstraction for In-Memory Cluster ...