aboutsummaryrefslogtreecommitdiff
path: root/files/zh-tw/web/javascript/closures
diff options
context:
space:
mode:
Diffstat (limited to 'files/zh-tw/web/javascript/closures')
-rw-r--r--files/zh-tw/web/javascript/closures/index.html8
1 files changed, 4 insertions, 4 deletions
diff --git a/files/zh-tw/web/javascript/closures/index.html b/files/zh-tw/web/javascript/closures/index.html
index fbac2c5b07..de8cb67e54 100644
--- a/files/zh-tw/web/javascript/closures/index.html
+++ b/files/zh-tw/web/javascript/closures/index.html
@@ -164,8 +164,8 @@ console.log(counter.value()); // logs 1
<p>這三個公有函式,皆為共享同一個環境的閉包。由於 JavaScript 的語法作用域,它們都能訪問 <code>privateCounter</code> 變數與 <code>changeBy</code> 函式。</p>
-<div class="note">
-<p>你應該也發現到我們定義了建立 counter 的匿名函式、而我們接著呼叫它,並給<code>counter</code> 變數指派了回傳值。我們也能在分離的變數 <code>makeCounter</code> 儲存函式並用其建立數個 counter。</p>
+<div class="notecard note">
+<p><strong>備註:</strong>你應該也發現到我們定義了建立 counter 的匿名函式、而我們接著呼叫它,並給<code>counter</code> 變數指派了回傳值。我們也能在分離的變數 <code>makeCounter</code> 儲存函式並用其建立數個 counter。</p>
</div>
<pre class="brush: js">var makeCounter = function() {
@@ -199,8 +199,8 @@ alert(counter2.value()); /* Alerts 0 */
<p>請注意 <code>counter1</code> 與 <code>counter2</code> 這兩個計數器是如何維護其獨立性的。每個閉包都以各自的閉包,在參照不同版本的 <code>privateCounter</code> 變數。每當呼叫其中一個計數器時,它會透過該變數的數值變更,改變語法作用域的環境。不過,在其中一個閉包的變數值改時,其他閉包的數值並不會受到影響。</p>
-<div class="note">
-<p>使用這種方法的閉包,提供了一些與物件導向程式設計的益處,尤其是資料隱藏與封裝。</p>
+<div class="notecard note">
+<p><strong>備註:</strong>使用這種方法的閉包,提供了一些與物件導向程式設計的益處,尤其是資料隱藏與封裝。</p>
</div>
<h2 id="在迴圈建立閉包:一個常見錯誤">在迴圈建立閉包:一個常見錯誤</h2>