JavaScript Reserved Words

There are some reserved words that you can not use as a variable name in JavaScript. if you use it, you will encounter an error. The following is a list of reserved words.

  • abstract
  • else
  • instanceof
  • switch
  • boolean
  • enum
  • int
  • synchronized
  • break
  • export
  • interface
  • this
  • byte
  • extends
  • long
  • throw
  • case
  • false
  • native
  • throws
  • catch
  • final
  • new
  • transient
  • char
  • finally
  • null
  • true
  • class
  • try
  • const
  • for
  • private
  • typeof
  • continue
  • function
  • protected
  • var
  • debugger
  • goto
  • public
  • void
  • default
  • if
  • return
  • volatile
  • delete
  • implements
  • short
  • while
  • do
  • import
  • static
  • with
  • double
  • in
  • super
  • float
  • package

The following code will throw an error.


let let = 1; 
//Uncaught SyntaxError: let is disallowed as a lexically bound name
let while = 1;
//Uncaught SyntaxError: Unexpected token while
                    

Conclusion

In this section, you learned about the reserved words in JavaScript.
In next section, you will learn about Scope in JavaScript.