aboutsummaryrefslogtreecommitdiff
path: root/files/zh-cn/web/javascript/closures/index.html
diff options
context:
space:
mode:
authorIrvin <irvinfly@gmail.com>2022-02-16 02:08:24 +0800
committerIrvin <irvinfly@gmail.com>2022-02-16 02:35:54 +0800
commit8d1313c84cc82d81363ed62b75baedb9a65ff2e3 (patch)
treefcf531cdea6491c848cc17fc44efe5b18466e54b /files/zh-cn/web/javascript/closures/index.html
parenta2617e517fe48fbd0fc283e05c82e32765a3fb12 (diff)
downloadtranslated-content-8d1313c84cc82d81363ed62b75baedb9a65ff2e3.tar.gz
translated-content-8d1313c84cc82d81363ed62b75baedb9a65ff2e3.tar.bz2
translated-content-8d1313c84cc82d81363ed62b75baedb9a65ff2e3.zip
remove font tag in zh-CN
Diffstat (limited to 'files/zh-cn/web/javascript/closures/index.html')
-rw-r--r--files/zh-cn/web/javascript/closures/index.html2
1 files changed, 1 insertions, 1 deletions
diff --git a/files/zh-cn/web/javascript/closures/index.html b/files/zh-cn/web/javascript/closures/index.html
index 4374a1571c..4b732a1a0d 100644
--- a/files/zh-cn/web/javascript/closures/index.html
+++ b/files/zh-cn/web/javascript/closures/index.html
@@ -247,7 +247,7 @@ setupHelp();
<p>运行这段代码后,您会发现它没有达到想要的效果。无论焦点在哪个<code>input</code>上,显示的都是关于年龄的信息。</p>
-<p>原因是赋值给 <code>onfocus</code> 的是闭包。这些闭包是由他们的函数定义和在 <code>setupHelp</code> 作用域中捕获的环境所组成的。这三个闭包在循环中被创建,但他们共享了同一个词法作用域,在这个作用域中存在一个变量item。这是因为变量<font face="consolas, Liberation Mono, courier, monospace">item</font>使用var进行声明,由于变量提升,所以具有函数作用域。当<code>onfocus</code>的回调执行时,<code>item.help</code>的值被决定。由于循环在事件触发之前早已执行完毕,变量对象<code>item</code>(被三个闭包所共享)已经指向了<code>helpText</code>的最后一项。</p>
+<p>原因是赋值给 <code>onfocus</code> 的是闭包。这些闭包是由他们的函数定义和在 <code>setupHelp</code> 作用域中捕获的环境所组成的。这三个闭包在循环中被创建,但他们共享了同一个词法作用域,在这个作用域中存在一个变量item。这是因为变量<code>item</code>使用var进行声明,由于变量提升,所以具有函数作用域。当<code>onfocus</code>的回调执行时,<code>item.help</code>的值被决定。由于循环在事件触发之前早已执行完毕,变量对象<code>item</code>(被三个闭包所共享)已经指向了<code>helpText</code>的最后一项。</p>
<p>解决这个问题的一种方案是使用更多的闭包:特别是使用前面所述的函数工厂:</p>