JS Reserved Words 🎯

beginner
8 min

JS Reserved Words 🎯

Welcome to our comprehensive guide on JavaScript Reserved Words! In this tutorial, we'll delve into the world of JavaScript, exploring keywords that are off-limits for variable and function names. 📝

What are JavaScript Reserved Words?

JavaScript reserved words are predefined keywords that have special meanings in the language. They cannot be used as variable or function names as they are reserved for specific purposes within JavaScript. 💡

List of JavaScript Reserved Words 📝

Here's a list of JavaScript reserved words. Familiarizing yourself with them will help you avoid naming conflicts and make your code more readable.

javascript
abstract const new switch arguments continue return this boolean break short throw byte case super throw char catch switch transient class charCodeAt synchronized true const class symbols try debugger catch systemId typeof definingProperty catchBinding systemPrincipal typeofName delete charCodeAtLength tagName typeofObject do finally templatestrings undefined double for template unicode else function this unreachable enum goto throw unsigned eval if throwException union export imports transient unsubscriptable extends in true unsafe finally instanceof try unwatch final int typeof use float interface typeof var for let typeofName void function long typeofObject volatile get native umlaut wait goto null undefined while implements package unlimited with import private unpack yield in protected unprototype __proto__ instanceof public unshift __hasInstance interface return unionType __defineGetter__ let short unique __defineSetter__ link static unwatch __lookupGetter__ long staticGet unrestricted __lookupSetter__ native super unsynchronized __lookupWith__ new switch unwrap __proto__get__ number synchronized upvar __proto__hasProperty__ package throw usage __proto__isPrototypeOf__ private throwException var __proto__set__ protected true volatile __proto__toLocaleString__ public try with __proto__valueOf__ static typeOf x __proto____

Quiz Time 🎓

Quick Quiz
Question 1 of 1

Which of the following words cannot be used as a variable name in JavaScript?

Quick Quiz
Question 1 of 1

What is the purpose of the `__proto__` property in JavaScript?

Practice Time 🕰️

Now that you've learned about JavaScript reserved words, let's put your knowledge into practice!

Try renaming the following variables and functions so they don't conflict with reserved words:

javascript
const class = "student"; function if(num) { //... }

Solution

javascript
const className = "student"; function checkNum(num) { //... }

In the first example, we've renamed the variable class to className to avoid naming conflicts with the reserved word class. In the second example, we've renamed the function if to checkNum because the keyword if is reserved in JavaScript. 💡

Wrapping Up 🎁

By understanding JavaScript reserved words, you can write cleaner, more efficient, and easier-to-read code. In this tutorial, we covered the list of reserved words in JavaScript, along with practical examples and a quiz to test your understanding. Happy coding! 💡💻