Javascript Reserved Keywords

Javascript Reserved Keywords

In JavaScript, reserved keywords are predefined words that have a special meaning in the language syntax. They cannot be used as identifiers (e.g., variable names, function names). These keywords fall into several categories:

Category Keywords
Language Features break, case, catch, class, const, continue, debugger, default, delete, do, else, enum, export, extends, finally, for, function, if, import, in, instanceof, let, new, return, super, switch, this, throw, try, typeof, var, void, while, with, yield
Future Use implements, interface, package, private, protected, public, static
Literals null, true, false
Strict Mode Reserved arguments, eval
Modules await (used with async functions)

List of Event Handlers

event handler names (like onclick, onload, etc.) should not be used as variable names in JavaScript because they are associated with DOM event handling in HTML. Here's a list of common event handlers in JavaScript:

Event Category Event Handlers
Mouse Events onclick, ondblclick, onmousedown, onmouseup, onmouseover, onmousemove, onmouseout, onmouseenter, onmouseleave
Keyboard Events onkeydown, onkeypress, onkeyup
Form Events onblur, onchange, onfocus, oninput, oninvalid, onreset, onsearch, onselect, onsubmit
Window/Document Events onabort, onafterprint, onbeforeprint, onbeforeunload, onerror, onhashchange, onload, onmessage, onoffline, ononline, onpagehide, onpageshow, onpopstate, onresize, onscroll, onstorage, onunload
Drag and Drop Events ondrag, ondragend, ondragenter, ondragleave, ondragover, ondragstart, ondrop
Clipboard Events oncopy, oncut, onpaste
Media Events oncanplay, oncanplaythrough, oncuechange, ondurationchange, onemptied, onended, onloadeddata, onloadedmetadata, onloadstart, onpause, onplay, onplaying, onprogress, onratechange, onseeked, onseeking, onstalled, onsuspend, ontimeupdate, onvolumechange, onwaiting
Touch Events ontouchcancel, ontouchend, ontouchmove, ontouchstart
Miscellaneous Events onwheel, oncontextmenu, onanimationstart, onanimationend, onanimationiteration, ontransitionend

Usage Note:

  • Avoid using these keywords as variable, function, or identifier names.
  • Some keywords (e.g., enum, implements) may not be fully implemented in JavaScript but are reserved for future use.
Previous Next