JavaScript 予約語

❮ 前章へ 次章へ ❯

JavaScript の予約語

JavaScript では、次の予約語は変数、ラベル、関数名に使用することはできません:
abstract arguments await* boolean
break byte case catch
char class* const continue
debugger default delete do
double else enum* eval
export* extends* false final
finally float for function
goto if implements import*
in instanceof int interface
let* long native new
null package private protected
public return short static
super* switch synchronized this
throw throws transient true
try typeof var void
volatile while with yield
* 付きの予約語は、ECMAScript 5 および 6 で新しく追加されました。

さまざまな JavaScript バージョンの詳細は、JS バージョンの章をご覧ください。


削除された予約語

次の予約語は、ECMAScript 5/6 標準から削除されています:
abstract boolean byte char
double final float goto
int long native short
synchronized throws transient volatile

これらの単語を変数として使用しないでください。 すべてのブラウザが、ECMAScript 5/6 を完全にサポートしてはいません。


JavaScript オブジェクト、プロパティ、メソッド

また、JavaScript の組み込みオブジェクト、プロパティ、メソッドの名前も使用しないでください:
Array Date eval function
hasOwnProperty Infinity isFinite isNaN
isPrototypeOf length Math NaN
name Number オブジェクト prototype
String toString undefined valueOf

また、

Java の予約語

JavaScript は Java とよく一緒に使用されます。JavaScript 識別子として、Java オブジェクトとプロパティを使用しないでください:
getClass java JavaArray javaClass
Javaオブジェクト JavaPackage

その他の予約語

JavaScript は、多くのアプリケーションでプログラミング言語として使用できます。

HTML および Window オブジェクトとプロパティの名前も使用しないでください:
alert all anchor anchors
area assign blur button
checkbox clearInterval clearTimeout clientInformation
close closed confirm constructor
crypto decodeURI decodeURIComponent defaultStatus
document element elements embed
embeds encodeURI encodeURIComponent escape
event fileUpload focus form
forms frame innerHeight innerWidth
layer layers link location
mimeTypes navigate navigator frames
frameRate hidden history image
images offscreenBuffering open opener
option outerHeight outerWidth packages
pageXOffset pageYOffset parent parseFloat
parseInt password pkcs11 plugin
prompt propertyIsEnum radio reset
screenX screenY scroll secure
select self setInterval setTimeout
status submit taint text
textarea top unescape untaint
window

HTML イベントハンドラ

さらに、すべての HTML イベントハンドラ名も使用しないでください。

例:
onblur onclick onerror onfocus
onkeydown onkeypress onkeyup onmouseover
onload onmouseup onmousedown onsubmit

❮ 前章へ 次章へ ❯