From f45e9e070c93ebbd83d488bdd775987a4d75c201 Mon Sep 17 00:00:00 2001 From: t7yang Date: Mon, 10 Jan 2022 08:38:08 +0800 Subject: fix yari h2m dry run errors --- files/zh-tw/web/javascript/guide/functions/index.html | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) (limited to 'files/zh-tw/web/javascript/guide/functions') diff --git a/files/zh-tw/web/javascript/guide/functions/index.html b/files/zh-tw/web/javascript/guide/functions/index.html index f71ccfa1e9..af19983b6f 100644 --- a/files/zh-tw/web/javascript/guide/functions/index.html +++ b/files/zh-tw/web/javascript/guide/functions/index.html @@ -72,12 +72,8 @@ y = mycar.make; // y 的值還是 "Honda"
var square = function(number) {return number * number};
 var x = square(4) //x 的值為 16
-
必要時,函式名稱可與函式表達式同時存在,並且可以用於在函式內部代指其本身(遞迴):
-
 
-
-
var factorial = function fac(n) {return n<2 ? 1 : n*fac(n-1)};
 
 console.log(factorial(3));
@@ -150,7 +146,7 @@ e = factorial(5); // e gets the value 120
 
 

There are other ways to call functions. There are often cases where a function needs to be called dynamically, or the number of arguments to a function vary, or in which the context of the function call needs to be set to a specific object determined at runtime. It turns out that functions are, themselves, objects, and these objects in turn have methods (see the Function object). One of these, the apply() method, can be used to achieve this goal.

-

Function scope

+

Function scope

Variables defined inside a function cannot be accessed from anywhere outside the function, because the variable is defined only in the scope of the function. However, a function can access all variables and functions defined inside the scope in which it is defined. In other words, a function defined in the global scope can access all variables defined in the global scope. A function defined inside another function can also access all variables defined in it's parent function and any other variable to which the parent function has access.

-- cgit v1.2.3-54-g00ecf