How to call a Javascript function expression
问题 Can someone please help me understand how to call this JS function expression var math = { 'factorial': function factorial(n) { if (n <= 1) return 1; return n * factorial(n - 1); } }; 回答1: Here you go. Should be self-evident: 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,