aboutsummaryrefslogtreecommitdiff
path: root/files/ja/web/javascript/reference/errors/bad_octal
diff options
context:
space:
mode:
Diffstat (limited to 'files/ja/web/javascript/reference/errors/bad_octal')
-rw-r--r--files/ja/web/javascript/reference/errors/bad_octal/index.html51
1 files changed, 51 insertions, 0 deletions
diff --git a/files/ja/web/javascript/reference/errors/bad_octal/index.html b/files/ja/web/javascript/reference/errors/bad_octal/index.html
new file mode 100644
index 0000000000..d3f5c51403
--- /dev/null
+++ b/files/ja/web/javascript/reference/errors/bad_octal/index.html
@@ -0,0 +1,51 @@
+---
+title: 'SyntaxError: "x" is not a legal ECMA-262 octal constant'
+slug: Web/JavaScript/Reference/Errors/Bad_octal
+tags:
+ - Errors
+ - JavaScript
+ - Strict Mode
+ - SynataxError
+ - Warning
+translation_of: Web/JavaScript/Reference/Errors/Bad_octal
+---
+<div>{{jsSidebar("Errors")}}</div>
+
+<h2 id="メッセージ">メッセージ</h2>
+
+<pre class="syntaxbox">Warning: SyntaxError: 08 is not a legal ECMA-262 octal constant.
+Warning: SyntaxError: 09 is not a legal ECMA-262 octal constant.
+</pre>
+
+<h2 id="エラータイプ">エラータイプ</h2>
+
+<p><a href="/ja/docs/Web/JavaScript/Reference/Strict_mode">strict モード</a> でのみ、{{jsxref("SyntaxError")}} の警告が出ます。</p>
+
+<h2 id="何がうまくいかなかったのか?">何がうまくいかなかったのか?</h2>
+
+<p>小数リテラルは、そのほかの十進数が続くゼロ(<code>0</code>)から開始できますが、先頭の <code>0</code> 以降の数値がすべて 8 以下の場合、数値は八進数として解釈されます。それゆえ、 <code>08</code> や <code>09</code> はあり得ないため、JavaScript はこれを警告します。</p>
+
+<p>八進数リテラルと八進数エスケープシーケンスは非推奨であり、追加の非推奨警告が発生することに注意してください。ECMAScript 6 以降では、小文字または大文字のラテンリテラル "O"(<code>0o</code> か <code>0O</code>)が続くゼロ始まりの構文が使用されます。詳細は、<a href="/ja/docs/Web/JavaScript/Reference/Lexical_grammar#Octal">lexical grammar</a> のページを見てください。</p>
+
+<h2 id="例">例</h2>
+
+<h3 id="無効な八進数">無効な八進数</h3>
+
+<pre class="brush: js example-bad">08;
+09;
+// SyntaxError: 08 is not a legal ECMA-262 octal constant
+// SyntaxError: octal literals and octal escape sequences are deprecated</pre>
+
+<h3 id="有効な八進数">有効な八進数</h3>
+
+<p>"o" の文字が続くゼロを使用します。</p>
+
+<pre class="brush: js example-good">0O755;
+0o644;
+</pre>
+
+<h2 id="関連項目">関連項目</h2>
+
+<ul>
+ <li><a href="/ja/docs/Web/JavaScript/Reference/Lexical_grammar#Octal">Lexical grammar</a></li>
+</ul>