aboutsummaryrefslogtreecommitdiff
path: root/files/zh-tw/web/javascript/guide/functions
diff options
context:
space:
mode:
authort7yang <t7yang@gmail.com>2022-01-10 08:38:08 +0800
committerIrvin <irvinfly@gmail.com>2022-02-16 02:35:54 +0800
commitf45e9e070c93ebbd83d488bdd775987a4d75c201 (patch)
treeaacef5edaf768a188cadc46860f5b6aaa74f39ef /files/zh-tw/web/javascript/guide/functions
parent8ccfa93045a6c119303566370999f59a0aae3b25 (diff)
downloadtranslated-content-f45e9e070c93ebbd83d488bdd775987a4d75c201.tar.gz
translated-content-f45e9e070c93ebbd83d488bdd775987a4d75c201.tar.bz2
translated-content-f45e9e070c93ebbd83d488bdd775987a4d75c201.zip
fix yari h2m dry run errors
Diffstat (limited to 'files/zh-tw/web/javascript/guide/functions')
-rw-r--r--files/zh-tw/web/javascript/guide/functions/index.html6
1 files changed, 1 insertions, 5 deletions
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" </pre>
<pre class="brush: js">var square = function(number) {return number * number};
var x = square(4) //x 的值為 16</pre>
-<div class="almost_half_cell" id="gt-res-content">
<div>必要時,函式名稱可與函式表達式同時存在,並且可以用於在函式內部代指其本身(遞迴):</div>
-<div> </div>
-</div>
-
<pre class="brush: js">var factorial = function fac(n) {return n&lt;2 ? 1 : n*fac(n-1)};
console.log(factorial(3));
@@ -150,7 +146,7 @@ e = factorial(5); // e gets the value 120
<p>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 <a href="/en-US/docs/JavaScript/Guide/Obsolete_Pages/Predefined_Core_Objects/Function_Object" title="Function Object"><code>Function</code> object</a>). One of these, the <a href="/en-US/docs/JavaScript/Reference/Global_Objects/Function/apply" title="apply"><code>apply()</code></a> method, can be used to achieve this goal.</p>
-<h2 class="deki-transform" id="Function_scope">Function scope</h2>
+<h2 id="Function_scope">Function scope</h2>
<p>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.</p>