如何调用 Javascript 函数表达式
How to call a Javascript function expression
谁能帮我理解如何调用这个 JS 函数表达式
var math = {
'factorial': function factorial(n) {
if (n <= 1)
return 1;
return n * factorial(n - 1);
}
};
给你。应该是不言自明的:
var math =
{
'factorial': function factorial(n)
{
if (n <= 1)
return 1;
return n * factorial(n - 1);
}
};
var result = math.factorial(3);
// For the purposes of illustration, we will use document.write to output
// the result. document.write is generally not a good idea, however!
document.write(result);
谁能帮我理解如何调用这个 JS 函数表达式
var math = {
'factorial': function factorial(n) {
if (n <= 1)
return 1;
return n * factorial(n - 1);
}
};
给你。应该是不言自明的:
var math =
{
'factorial': function factorial(n)
{
if (n <= 1)
return 1;
return n * factorial(n - 1);
}
};
var result = math.factorial(3);
// For the purposes of illustration, we will use document.write to output
// the result. document.write is generally not a good idea, however!
document.write(result);