ITADN

Short-circuit execution of the RHS

#5Closedjordanbtucker 创建于 2023-07-16
J
jordanbtuckercommented
This is the first Babel example in the linked gist: - https://github.com/babel/babel/blob/5f74b510ff251af5bf7fbbf25c1c934ffcb6df52/packages/babel-helpers/src/helpers/wrapRegExp.js#L26-L27 ```javascript var indices = result.indices; if (indices) indices.groups = buildGroups(indices, this); ``` could be rewritten as ```javascript var indices = result.indices; indices?.groups = buildGroups(indices, this); ``` Since both code examples are equivalent, does that mean that optional chaining assignment syntax would prevent the RHS (i.e. `buildGroups(indices, this)`) from being evaluated if `indices` is `undefined`?
关闭于 2023-07-18 3 条评论