Please note, this is a STATIC archive of website developer.mozilla.org from 03 Nov 2016, cach3.com does not collect or store any user information, there is no "phishing" involved.

SyntaxError: "x" is not a legal ECMA-262 octal constant

この記事は編集レビューを必要としています。ぜひご協力ください

メッセージ

Warning: SyntaxError: 08 is not a legal ECMA-262 octal constant.
Warning: SyntaxError: 09 is not a legal ECMA-262 octal constant.

エラータイプ

strict モード でのみ、SyntaxError の警告が出ます。

何がうまくいかなかったのか?

小数リテラルは、そのほかの十進数が続くゼロ(0)から開始できますが、先頭の 0 以降の数値がすべて 8 以下の場合、数値は八進数として解釈されます。それゆえ、 0809 はあり得ないため、JavaScript はこれを警告します。

八進数リテラルと八進数エスケープシーケンスは非推奨であり、追加の非推奨警告が発生することに注意してください。ECMAScript 6 以降では、小文字または大文字のラテンリテラル "O"(0o0O)が続くゼロ始まりの構文が使用されます。詳細は、lexical grammar のページを見てください。

無効な八進数

08;
09;
// SyntaxError: 08 is not a legal ECMA-262 octal constant
// SyntaxError: octal literals and octal escape sequences are deprecated

有効な八進数

"o" の文字が続くゼロを使用します。

0O755;
0o644;

関連項目

ドキュメントのタグと貢献者

 このページの貢献者: YuichiNukiyama
 最終更新者: YuichiNukiyama,