aboutsummaryrefslogtreecommitdiff
path: root/files/zh-cn
diff options
context:
space:
mode:
author1sm <31946591+1sm23@users.noreply.github.com>2021-04-27 23:35:46 +0800
committerGitHub <noreply@github.com>2021-04-27 23:35:46 +0800
commit212b7aa950a9cb226ed4e8c18aa35897273bd515 (patch)
treecc2cce400ac7ee0d53c12039c9ade5ca5a2f9f34 /files/zh-cn
parenta7659087cce7e83e05f0cf725333bc98a7086cff (diff)
downloadtranslated-content-212b7aa950a9cb226ed4e8c18aa35897273bd515.tar.gz
translated-content-212b7aa950a9cb226ed4e8c18aa35897273bd515.tar.bz2
translated-content-212b7aa950a9cb226ed4e8c18aa35897273bd515.zip
Update /web/javascript/reference/operators/this, zh-CN (#667)
fix: zh-cn 'this' typographical errors and translation
Diffstat (limited to 'files/zh-cn')
-rw-r--r--files/zh-cn/web/javascript/reference/operators/this/index.html13
1 files changed, 7 insertions, 6 deletions
diff --git a/files/zh-cn/web/javascript/reference/operators/this/index.html b/files/zh-cn/web/javascript/reference/operators/this/index.html
index a3378079ac..0962ff2a6e 100644
--- a/files/zh-cn/web/javascript/reference/operators/this/index.html
+++ b/files/zh-cn/web/javascript/reference/operators/this/index.html
@@ -129,19 +129,20 @@ new Bad(); // ReferenceError</pre>
<h3 id="函数上下文中的_this">函数上下文中的 this</h3>
-<pre dir="rtl">// An object can be passed as the first argument to call or apply and this will be bound to it.
+<pre class="brush:js">
+// 对象可以作为 bind 或 apply 的第一个参数传递,并且该参数将绑定到该对象。
var obj = {a: 'Custom'};
-// We declare a variable and the variable is assigned to the global window as its property.
+// 声明一个变量,并将该变量作为全局对象 window 的属性。
var a = 'Global';
function whatsThis() {
- return this.a; // The value of this is dependent on how the function is called
+ return this.a; // this 的值取决于函数被调用的方式
}
-whatsThis(); // 'Global' as this in the function isn't set, so it defaults to the global/window object
-whatsThis.call(obj); // 'Custom' as this in the function is set to obj
-whatsThis.apply(obj); // 'Custom' as this in the function is set to obj
+whatsThis(); // 'Global' 因为在这个函数中 this 没有被设定,所以它默认为 全局/ window 对象
+whatsThis.call(obj); // 'Custom' 因为函数中的 this 被设置为obj
+whatsThis.apply(obj); // 'Custom' 因为函数中的 this 被设置为obj
</pre>
<h3 id="this_和对象转换">this 和对象转换</h3>