Skip to content

Commit

Permalink
[zh-cn]: revert SyntaxError
Browse files Browse the repository at this point in the history
  • Loading branch information
fuchunhui committed Oct 29, 2024
1 parent 7da7d63 commit ac723e3
Showing 1 changed file with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -102,17 +102,17 @@ const object = {};
object?.property = 1; // SyntaxError: Invalid left-hand side in assignment
```
[模板字符串标签](/zh-CN/docs/Web/JavaScript/Reference/Template_literals#带标签的模板)不能是可选链(参见[语法错误:带标签的模板不能与可选链一起使用](/zh-CN/docs/Web/JavaScript/Reference/Errors/Bad_optional_template)):
[模板字符串标签](/zh-CN/docs/Web/JavaScript/Reference/Template_literals#带标签的模板)不能是可选链(参见 [SyntaxError: tagged template cannot be used with optional chain](/zh-CN/docs/Web/JavaScript/Reference/Errors/Bad_optional_template)):
```js-nolint example-bad
String?.raw`Hello, world!`;
String.raw?.`Hello, world!`; // 语法错误:可选链上的标签模板无效
String.raw?.`Hello, world!`; // SyntaxError: Invalid tagged template on optional chain
```
{{jsxref("Operators/new", "new")}} 表达式的构造函数不能是可选链(参见[语法错误:new 关键字不能与可选链一起使用](/zh-CN/docs/Web/JavaScript/Reference/Errors/Bad_new_optional)):
{{jsxref("Operators/new", "new")}} 表达式的构造函数不能是可选链(参见 [SyntaxError: new keyword cannot be used with an optional chain](/zh-CN/docs/Web/JavaScript/Reference/Errors/Bad_new_optional)):
```js-nolint example-bad
new Intl?.DateTimeFormat(); // 语法错误:new 表达式的可选链无效
new Intl?.DateTimeFormat(); // SyntaxError: Invalid optional chain from new expression
new Map?.();
```
Expand Down Expand Up @@ -151,7 +151,7 @@ const prop =
```js
const potentiallyNullObj = null;
const prop = (potentiallyNullObj?.a).b;
// 类型错误:不能读取未定义的属性(读取“b”)
// TypeError: Cannot read properties of undefined (reading 'b')
```
这等价于:
Expand Down

0 comments on commit ac723e3

Please sign in to comment.