Skip to content

Commit

Permalink
[zh-cn] sync translated content (#22373)
Browse files Browse the repository at this point in the history
Co-authored-by: Allo <[email protected]>
  • Loading branch information
mdn-bot and yin1999 authored Jul 13, 2024
1 parent 7bd80e3 commit 62262ae
Show file tree
Hide file tree
Showing 12 changed files with 90 additions and 402 deletions.
5 changes: 4 additions & 1 deletion files/zh-cn/_redirects.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2525,14 +2525,17 @@
/zh-CN/docs/Web/JavaScript/Reference/Date/toJSON /zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Date/toJSON
/zh-CN/docs/Web/JavaScript/Reference/Date/valueOf /zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Date/valueOf
/zh-CN/docs/Web/JavaScript/Reference/Deprecated_and_obsolete_features/The_legacy_Iterator_protocol /zh-CN/docs/Web/JavaScript/Reference/Deprecated_and_obsolete_features
/zh-CN/docs/Web/JavaScript/Reference/Errors/Bad_octal /zh-CN/docs/Web/JavaScript/Reference/Errors/Deprecated_octal
/zh-CN/docs/Web/JavaScript/Reference/Errors/Bad_octal /zh-CN/docs/Web/JavaScript/Reference/Errors/Deprecated_octal_literal
/zh-CN/docs/Web/JavaScript/Reference/Errors/Bad_return_or_yield /zh-CN/docs/Web/JavaScript/Reference/Errors/Bad_return
/zh-CN/docs/Web/JavaScript/Reference/Errors/Cant_access_property /zh-CN/docs/Web/JavaScript/Reference/Errors/Unexpected_type
/zh-CN/docs/Web/JavaScript/Reference/Errors/Deprecated_String_generics /zh-CN/docs/Web/JavaScript/Reference/Deprecated_and_obsolete_features
/zh-CN/docs/Web/JavaScript/Reference/Errors/Deprecated_expression_closures /zh-CN/docs/Web/JavaScript/Reference/Deprecated_and_obsolete_features
/zh-CN/docs/Web/JavaScript/Reference/Errors/Deprecated_octal /zh-CN/docs/Web/JavaScript/Reference/Errors/Deprecated_octal_literal
/zh-CN/docs/Web/JavaScript/Reference/Errors/Deprecated_toLocaleFormat /zh-CN/docs/Web/JavaScript/Reference/Deprecated_and_obsolete_features
/zh-CN/docs/Web/JavaScript/Reference/Errors/Malformed_formal_parameter /zh-CN/docs/Web/JavaScript/Reference/Errors/Missing_formal_parameter
/zh-CN/docs/Web/JavaScript/Reference/Errors/Missing_semicolon_before_statement /zh-CN/docs/Web/JavaScript/Reference/Errors/Unexpected_token
/zh-CN/docs/Web/JavaScript/Reference/Errors/Not_a_codepoint /zh-CN/docs/Web/JavaScript/Reference/Errors/Not_a_valid_code_point
/zh-CN/docs/Web/JavaScript/Reference/Errors/Unterminated_string_literal /zh-CN/docs/Web/JavaScript/Reference/Errors/String_literal_EOL
/zh-CN/docs/Web/JavaScript/Reference/Errors/不能添加属性 /zh-CN/docs/Web/JavaScript/Reference/Errors/Cant_assign_to_property
/zh-CN/docs/Web/JavaScript/Reference/Function /zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Function
/zh-CN/docs/Web/JavaScript/Reference/Function/apply /zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Function/apply
Expand Down
26 changes: 5 additions & 21 deletions files/zh-cn/_wikihistory.json
Original file line number Diff line number Diff line change
Expand Up @@ -23067,10 +23067,6 @@
"modified": "2020-10-15T21:55:00.550Z",
"contributors": ["zhangchen", "WayneCui"]
},
"Web/HTTP/Headers/Large-Allocation": {
"modified": "2020-10-15T21:56:09.177Z",
"contributors": ["wyapx", "crper", "shevacjs"]
},
"Web/HTTP/Headers/Last-Modified": {
"modified": "2020-10-15T21:55:00.234Z",
"contributors": ["WayneCui"]
Expand Down Expand Up @@ -24991,18 +24987,14 @@
"modified": "2020-03-12T19:45:21.241Z",
"contributors": ["Ende93"]
},
"Web/JavaScript/Reference/Errors/Deprecated_octal": {
"Web/JavaScript/Reference/Errors/Deprecated_octal_literal": {
"modified": "2020-03-12T19:46:39.086Z",
"contributors": ["WayneCui"]
},
"Web/JavaScript/Reference/Errors/Deprecated_source_map_pragma": {
"modified": "2020-03-12T19:45:31.617Z",
"contributors": ["Kaede_Shinoda", "Ende93"]
},
"Web/JavaScript/Reference/Errors/Equal_as_assign": {
"modified": "2020-03-12T19:44:21.268Z",
"contributors": ["niaodan2b"]
},
"Web/JavaScript/Reference/Errors/Getter_only": {
"modified": "2020-03-12T19:46:35.397Z",
"contributors": ["WayneCui"]
Expand Down Expand Up @@ -25083,10 +25075,6 @@
"modified": "2020-03-12T19:46:25.852Z",
"contributors": ["WayneCui"]
},
"Web/JavaScript/Reference/Errors/Missing_semicolon_before_statement": {
"modified": "2020-03-12T19:44:58.615Z",
"contributors": ["Davont", "jitingsun"]
},
"Web/JavaScript/Reference/Errors/More_arguments_needed": {
"modified": "2020-03-12T19:45:18.099Z",
"contributors": ["Ende93"]
Expand Down Expand Up @@ -25163,6 +25151,10 @@
"modified": "2020-03-12T19:45:16.824Z",
"contributors": ["xgqfrms-GitHub", "Ende93"]
},
"Web/JavaScript/Reference/Errors/String_literal_EOL": {
"modified": "2020-03-12T19:45:03.493Z",
"contributors": ["Ende93", "luckyG0429"]
},
"Web/JavaScript/Reference/Errors/Too_much_recursion": {
"modified": "2020-03-12T19:43:57.558Z",
"contributors": ["Jack-Q"]
Expand All @@ -25171,10 +25163,6 @@
"modified": "2020-03-12T19:45:21.644Z",
"contributors": ["Ende93"]
},
"Web/JavaScript/Reference/Errors/Undefined_prop": {
"modified": "2020-03-12T19:45:16.927Z",
"contributors": ["Ende93"]
},
"Web/JavaScript/Reference/Errors/Unexpected_token": {
"modified": "2020-03-12T19:45:18.592Z",
"contributors": ["Ende93"]
Expand All @@ -25187,10 +25175,6 @@
"modified": "2020-03-12T19:46:23.117Z",
"contributors": ["Lxio", "WayneCui"]
},
"Web/JavaScript/Reference/Errors/Unterminated_string_literal": {
"modified": "2020-03-12T19:45:03.493Z",
"contributors": ["Ende93", "luckyG0429"]
},
"Web/JavaScript/Reference/Errors/in_operator_no_object": {
"modified": "2020-03-12T19:46:27.485Z",
"contributors": ["WayneCui"]
Expand Down
32 changes: 5 additions & 27 deletions files/zh-cn/learn/javascript/first_steps/what_went_wrong/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -173,24 +173,6 @@ Math.floor(Math.random() * 100) + 1;

代码中还会遇到其他常见错误。本节将指出其中的大部分。

### SyntaxError: missing ; before statement<br>(语法错误:语句缺少分号)

这个错误通常意味着你漏写了一行代码最后的分号,但是此类错误有时候会更加隐蔽。例如如果我们把 `checkGuess()` 函数中的这一行 :

```js
let userGuess = Number(guessField.value);
```

改成

```js
let userGuess === Number(guessField.value);
```

将抛出一个错误。因为系统认为你在做其他事情。请不要把赋值运算符(`=`,为一个变量赋值)和严格等于运算符(`===`,比较两个值是否相等,返回 `true`/`false`)弄混淆。

> **备注:** 此错误的更多详细信息请参考 [SyntaxError: missing ; before statement](/zh-CN/docs/Web/JavaScript/Reference/Statements)
### 不管输入什么程序总说“你猜对了!”

这是混淆赋值和严格等于运算符的又一症状。例如我们把 `checkGuess()` 里的:
Expand All @@ -207,13 +189,13 @@ if (userGuess = randomNumber) {
因为条件永远返回 `true`,使得程序报告你猜对了。小心哦!
### SyntaxError: missing ) after argument list<br>(语法错误:参数表末尾缺少括号)
### SyntaxError: missing ) after argument list
这个很简单。通常意味着函数/方法调用后的结束括号忘写了。
> **备注:** 有关此错误的更多详细信息请参考: [SyntaxError: missing ) after argument list](/zh-CN/docs/Web/JavaScript/Reference/Errors/Missing_parenthesis_after_argument_list)。
### SyntaxError: missing : after property id<br>(语法错误:属性 ID 后缺少冒号)
### SyntaxError: missing : after property id
JavaScript 对象的形式有错时通常会导致此类错误,如果把
Expand All @@ -229,21 +211,17 @@ function checkGuess( {
浏览器会认为我们试图将函数的内容当作参数传回函数。写圆括号时要小心!
### SystaxError: missing } after function body<br>(语法错误:函数体末尾缺少花括号)
### SystaxError: missing } after function body
这个简单。通常意味着函数或条件结构中丢失了一个花括号。如果我们将 `checkGuess()` 函数末尾的花括号删除,就会得到这个错误。
### SyntaxError: expected expression, got '_string_'<br>(语法错误:得到一个 '_string_' 而非表达式)
或者
### SyntaxError: unterminated string literal<br>(语法错误:字符串字面量未正常结束)
### SyntaxError: expected expression, got '_string_' 或 SyntaxError: string literal contains an unescaped line break
这个错误通常意味着字符串两端的引号漏写了一个。如果你漏写了字符串开始的引号,将得到第一条出错信息,这里的 '_string'_ 将被替换为浏览器发现的意外字符。如果漏写了末尾的引号将得到第二条。
对于所有的这些错误,想想我们在实例中是如何逐步解决的。错误出现时,转到错误所在的行观察是否能发现问题所在。记住,错误不一定在那一行,错误的原因也可能和我们在上面所说的不同!
> **备注:** 有关这些错误的更多详细信息请参考:[SyntaxError: Unexpected token](/zh-CN/docs/Web/JavaScript/Reference/Errors/Unexpected_token) 以及 [SyntaxError: unterminated string literal](/zh-CN/docs/Web/JavaScript/Reference/Errors/Unterminated_string_literal)。
> **备注:** 有关这些错误的更多详细信息请参考:[SyntaxError: Unexpected token](/zh-CN/docs/Web/JavaScript/Reference/Errors/Unexpected_token) 以及 [SyntaxError: string literal contains an unescaped line break](/zh-CN/docs/Web/JavaScript/Reference/Errors/String_literal_EOL)。
## 小结
Expand Down
2 changes: 0 additions & 2 deletions files/zh-cn/web/http/headers/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -364,8 +364,6 @@ _[在此处](/zh-CN/docs/Glossary/CORS)了解更多关于 CORS。_
- : 包含消息发出的日期和时间。
- {{HTTPHeader("Early-Data")}} {{experimental_inline}}
- : 指示请求已在 TLS 早期数据中传送。
- {{HTTPHeader("Large-Allocation")}} {{deprecated_inline}}
- : 告诉浏览器正在加载的页面将要执行大量分配。
- {{HTTPHeader("Link")}}
- : [`Link`](https://datatracker.ietf.org/doc/html/rfc5988#section-5) 实体标头字段提供了一种在 HTTP 标头中序列化一个或多个链接的方法。它在语义上等同于 HTML 的 {{HTMLElement("link")}} 元素。
- {{HTTPHeader("Push-Policy")}} {{experimental_inline}}
Expand Down
77 changes: 0 additions & 77 deletions files/zh-cn/web/http/headers/large-allocation/index.md

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
---
title: 'SyntaxError: "0"-prefixed octal literals are deprecated'
slug: Web/JavaScript/Reference/Errors/Deprecated_octal_literal
l10n:
sourceCommit: 4e0349ec31c38bebd56e56782170666e11ae5ad3
---

{{jsSidebar("Errors")}}

仅在 JavaScript [严格模式](/zh-CN/docs/Web/JavaScript/Reference/Strict_mode)下出现的异常“0-prefixed octal literals are deprecated; use the "0o" prefix instead”在使用了已被弃用的八进制字面量(`0` 后跟数字)时出现。

## 错误提示

```plain
SyntaxError: Octal literals are not allowed in strict mode. (V8-based)
SyntaxError: Decimals with leading zeros are not allowed in strict mode. (V8-based)
SyntaxError: Unexpected number (V8-based)
SyntaxError: "0"-prefixed octal literals are deprecated; use the "0o" prefix instead (Firefox)
SyntaxError: Decimal integer literals with a leading zero are forbidden in strict mode (Safari)
```

## 错误类型

语法错误({{jsxref("SyntaxError")}}),只出现于[严格模式](/zh-CN/docs/Web/JavaScript/Reference/Strict_mode)下。

## 哪里出错了?

八进制字面量已被弃用。在十进制整数前加上 `0` 时,实际上会将其转换为八进制字面量,这可能会令人感到惊讶。标准化的语法使用前导零后跟一个小写或大写的拉丁字母“O”(`0o``0O`)。

前导零总是被禁止的,即使字面量不是有效的八进制字面量语法(例如字面量包含数字 `8``9`,或者有小数点)。数字字面量仅在其值为 0 时才能以 `0` 开头。

## 示例

### 前导“0”形式的八进制字面量

```js example-bad
"use strict";

03;

// SyntaxError: "0"-prefixed octal literals are deprecated; use the "0o" prefix instead
```

### 有效的八进制数字

使用前导零后跟字母“o”或“O”:

```js example-good
0o3;
```

## 参见

- [词法文法](/zh-CN/docs/Web/JavaScript/Reference/Lexical_grammar#八进制)
Loading

0 comments on commit 62262ae

Please sign in to comment.