aboutsummaryrefslogtreecommitdiff
path: root/files/zh-cn/web/javascript/reference/errors/deprecated_octal
diff options
context:
space:
mode:
authorPeter Bengtsson <mail@peterbe.com>2020-12-08 14:40:17 -0500
committerPeter Bengtsson <mail@peterbe.com>2020-12-08 14:40:17 -0500
commit33058f2b292b3a581333bdfb21b8f671898c5060 (patch)
tree51c3e392513ec574331b2d3f85c394445ea803c6 /files/zh-cn/web/javascript/reference/errors/deprecated_octal
parent8b66d724f7caf0157093fb09cfec8fbd0c6ad50a (diff)
downloadtranslated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.gz
translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.bz2
translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.zip
initial commit
Diffstat (limited to 'files/zh-cn/web/javascript/reference/errors/deprecated_octal')
-rw-r--r--files/zh-cn/web/javascript/reference/errors/deprecated_octal/index.html67
1 files changed, 67 insertions, 0 deletions
diff --git a/files/zh-cn/web/javascript/reference/errors/deprecated_octal/index.html b/files/zh-cn/web/javascript/reference/errors/deprecated_octal/index.html
new file mode 100644
index 0000000000..ca56bc00ac
--- /dev/null
+++ b/files/zh-cn/web/javascript/reference/errors/deprecated_octal/index.html
@@ -0,0 +1,67 @@
+---
+title: 'SyntaxError: "0"-prefixed octal literals and octal escape seq. are deprecated'
+slug: Web/JavaScript/Reference/Errors/Deprecated_octal
+tags:
+ - JavaScript
+ - 严格模式
+ - 语法错误
+ - 错误提示
+translation_of: Web/JavaScript/Reference/Errors/Deprecated_octal
+---
+<div>{{jsSidebar("Errors")}}</div>
+
+<h2 id="错误提示">错误提示</h2>
+
+<pre class="syntaxbox">SyntaxError:
+"0"-prefixed octal literals and octal escape sequences are deprecated;
+for octal literals use the \"0o\" prefix instead
+</pre>
+
+<h2 id="错误类型">错误类型</h2>
+
+<p>语法错误({{jsxref("SyntaxError")}} ),只出现于<a href="/en-US/docs/Web/JavaScript/Reference/Strict_mode">严格模式</a>下。</p>
+
+<h2 id="哪里出错了?">哪里出错了?</h2>
+
+<p>八进制字面量与八进制转义序列语法已经被废弃,在严格模式下会报语法错误({{jsxref("SyntaxError")}})。在 ECMAScript 2015 及以后的规范中,标准语法是前导 0 后面跟一个大写或小写的拉丁文字母 "O" (<code>0o</code> 或 <code>0O)。</code></p>
+
+<h2 id="示例">示例</h2>
+
+<h3 id="前导0形式的八进制字面量">前导"0"形式的八进制字面量</h3>
+
+<pre class="brush: js example-bad">"use strict";
+
+03;
+
+// SyntaxError: "0"-prefixed octal literals and octal escape sequences
+// are deprecated</pre>
+
+<h3 id="八进制转义序列">八进制转义序列</h3>
+
+<pre class="brush: js example-bad">"use strict";
+
+"\251";
+
+// SyntaxError: "0"-prefixed octal literals and octal escape sequences
+// are deprecated
+</pre>
+
+<h3 id="合法的八进制数字">合法的八进制数字</h3>
+
+<p>使用前导 0 后面跟字母 "o" 或 "O" 的形式:</p>
+
+<pre class="brush: js example-good">0o3;
+</pre>
+
+<p>至于八进制转义序列,你可以使用十六进制转义序列来代替:</p>
+
+<pre class="brush: js example-good">'\xA9';</pre>
+
+<h2 id="相关内容">相关内容</h2>
+
+<ul>
+ <li><a href="/en-US/docs/Web/JavaScript/Reference/Lexical_grammar#Octal">Lexical grammar</a></li>
+ <li>
+ <p><a href="/en-US/docs/Web/JavaScript/Reference/Errors/Bad_octal">警告: 08/09 不是符合 ECMA-262 规范的八进制常量</a></p>
+ </li>
+</ul>