Skip to content

Optional chaining '?.' 章节部分翻译待更新 #884

@hemuyao

Description

@hemuyao

在二级标题:Other variants: ?.(), ?.[] 的示例下面,英文部分是:

Here, in both lines we first use the dot (userAdmin.admin) to get admin property, because we assume that the user object exists, so it’s safe read from it.

Then ?.() checks the left part: if the admin function exists, then it runs (that’s so for userAdmin). Otherwise (for userGuest) the evaluation stops without errors.

而中文部分是:

在这两行代码中,我们首先使用点符号(user1.admin)来获取 admin 属性,因为用户对象一定存在,因此可以安全地读取它。

然后 ?.() 会检查它左边的部分:如果 admin 函数存在,那么就调用运行它(对于 user1)。否则(对于 user2)运算停止,没有错误。

不知道为什么,中文翻译中,将userAddmin.admin改成了user1.admin,将userGuest改成了user2,导致看的时候一头雾水。

Metadata

Metadata

Assignees

No one assigned

    Labels

    SolvedProblem solved

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions