Skip to content
\n

function makeUser() {
\nreturn {
\nname: \"John\",
\nref: this
\n};
\n}

\n
    let user = makeUser();\n\n    alert(user.ref.age);\n
","upvoteCount":1,"answerCount":1,"acceptedAnswer":{"@type":"Answer","text":"

Hello,本教程已经说明

\n
\n

本教程的所有例子都默认采用严格模式,除非特别指定(非常少)。

\n
\n

在严格模式下 global 不会把 this 设置为 globalThis,而是为 undefined

\n

P.S. 同时可以把这个理解为默认行为,因为在现代前端开发绝大部分上下文都是暗含了开启严格模式的。

","upvoteCount":1,"url":"https://github.com/javascript-tutorial/zh.javascript.info/discussions/1062#discussioncomment-2980845"}}}
Discussion options

You must be logged in to vote

Hello,本教程已经说明

本教程的所有例子都默认采用严格模式,除非特别指定(非常少)。

在严格模式下 global 不会把 this 设置为 globalThis,而是为 undefined

P.S. 同时可以把这个理解为默认行为,因为在现代前端开发绝大部分上下文都是暗含了开启严格模式的。

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by songhn233
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #1061 on June 19, 2022 16:58.