function makeUser() {
\nreturn {
\nname: \"John\",
\nref: this
\n};
\n}
let user = makeUser();\n\n alert(user.ref.age);\nHello,本教程已经说明:
\n\n\n本教程的所有例子都默认采用严格模式,除非特别指定(非常少)。
\n
在严格模式下 global 不会把 this 设置为 globalThis,而是为 undefined
\nP.S. 同时可以把这个理解为默认行为,因为在现代前端开发绝大部分上下文都是暗含了开启严格模式的。
","upvoteCount":1,"url":"https://github.com/javascript-tutorial/zh.javascript.info/discussions/1062#discussioncomment-2980845"}}}-
function makeUser() { |
Beta Was this translation helpful? Give feedback.
-
|
Hello,本教程已经说明:
在严格模式下 global 不会把 this 设置为 globalThis,而是为 undefined P.S. 同时可以把这个理解为默认行为,因为在现代前端开发绝大部分上下文都是暗含了开启严格模式的。 |
Beta Was this translation helpful? Give feedback.
Hello,本教程已经说明:
在严格模式下 global 不会把 this 设置为 globalThis,而是为 undefined
P.S. 同时可以把这个理解为默认行为,因为在现代前端开发绝大部分上下文都是暗含了开启严格模式的。