iwantcoding.com
🔥 Daily 👥 Rooms 🏆 Top Log in Sign up

JS Reserved Words

Reserved words can't be used as variable, parameter, or property names. Most of them are familiar — a few are leftovers from never-shipped features.

Keywords (always reserved)

breakcasecatchclass
constcontinuedebuggerdefault
deletedoelseexport
extendsfalsefinallyfor
functionifimportin
instanceofnewnullreturn
superswitchthisthrow
truetrytypeofvar
voidwhilewithyield

Contextual keywords (only reserved in certain contexts)

asyncawaitletstatic
implementsinterfacepackageprivate
protectedpublicofas

Reserved for the future

These were reserved by older specs but mostly unused: enum, abstract, boolean, byte, char, double, final, float, goto, int, long, native, short, synchronized, throws, transient, volatile.

Not reserved but very confusing

JS
// Legal but evil
const undefined = 5;        // SHADOWS global undefined — don't do this
let NaN = "what";           // same — modern engines actually make NaN read-only

// These are NOT reserved words
let Infinity = 0;           // legal — also evil
Tip: When porting code from Java, Python, etc., watch for class, const, and private as variable names — they break silently in old browsers and explode in modern ones.

Example

Example
<!DOCTYPE html>
<html>
<body>

<p id="out"></p>

<script>
document.getElementById("out").textContent = "Hello from JS Reserved Words!";
</script>

</body>
</html>
Try it Yourself »

Exercise

Which keyword could replace a variable name to cause a syntax error in modern code?

Answer (one word):

Test yourself

Q1. Which is a reserved word in modern JS?
Q2. `let` is a…
Q3. Which was reserved for a future feature but rarely used?

Discussion

Loading…