JavaScript 보존된 단어

JavaScript 보존된 단어

JavaScript에서는 이 예약어를 변수, 표시자 또는 함수 이름으로 사용할 수 없습니다:

추상 arguments await* 부울
break 바이트 case catch
캐릭터 class* const continue
debugger default delete do
더블 else enum* eval
export* extends* false 최종
finally 플로츠 for function
goto if implements import*
in instanceof 인트 interface
let* 길이 네이티브 new
null package private protected
public return static
super* switch 동기화 this
throw throws 임시 true
try typeof var void
변수 while with yield

별표로 표시된 단어는 ECMAScript 5와 6의 새로운 단어입니다。

다음과 같은 JS 버전다른 JavaScript 버전에 대한 내용에 대해 더 알아보세요。

제거된 예약어

다음과 같은 예약어는 ECMAScript 5/6 표준에서 제거되었습니다:

추상 부울 바이트 캐릭터
더블 최종 플로츠 goto
인트 길이 네이티브
동기화 throws 임시 변수

이 예약어를 변수로 사용하지 마세요. 모든 브라우저가 ECMAScript 5/6를 완전히 지원하지 않습니다.

JavaScript 객체, 속성 및 메서드

JavaScript 내장 객체, 속성 및 메서드의 이름도 피해야 합니다:

Array Date eval function
hasOwnProperty Infinity isFinite isNaN
isPrototypeOf length Math NaN
name Number Object prototype
String toString undefined valueOf

Java 예약어

JavaScript는 Java와 함께 사용되는 경우가 많습니다. 일부 Java 객체와 속성을 JavaScript 식별자로 사용하는 것을 피해야 합니다:

getClass java JavaArray javaClass
JavaObject 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