【发布时间】:2016-04-19 10:27:53
【问题描述】:
我在 node.js 中有一个构造函数,如下所示。
function Tree() {
//Redirect to other functions depends upon argument count.
}
我创建了类似的对象
var theTree = new Tree('Redwood');
var theTree = new Tree('Redwood',5);
var theTree = new Tree('Redwood',10,"USA");
我的要求是我想根据传入构造函数的参数数量重定向到不同的函数。如何找到参数的数量?
【问题讨论】:
-
arguments.length inside function Tree() 应该可以解决问题。
标签: javascript angularjs node.js object constructor