What are the keywords of javascript

PHPz
Release: 2023-04-24 15:22:25
Original
1184 people have browsed it

JavaScript is a programming language that is widely used in both front-end and back-end development. However, in JavaScript code, there are some words that are reserved keywords. These keywords have special meanings and functions and cannot be used as identifiers such as variable names or function names.

First of all, we need to understand what keywords are. Keywords refer to words or symbols that have been specified by a programming language as having a fixed meaning. For example, if, for, while, etc. in JavaScript are all keywords. These keywords play an important role in the syntax parsing and compilation process.

In JavaScript, the following is a list of reserved keywords:

  • break
  • case
  • catch
  • const
  • continue
  • debugger
  • default
  • delete
  • do
  • else
  • export
  • extends
  • finally
  • for
  • function
  • if
  • import
  • in
  • instanceof
  • new
  • return
  • super
  • switch
  • this
  • throw
  • try
  • typeof
  • var
  • void
  • while
  • with
  • yield

These reserved keywords have special meanings and cannot be used to define identifiers such as variables, functions, and object properties. If these keywords are used as identifiers, syntax errors will occur and the code will not run properly.

Let’s take a look at an example of a syntax error that occurs when using reserved keywords:

var function = "hello"; // 出现语法错误,不能用function作为变量名
Copy after login

So, how to avoid using reserved keywords? Other identifiers can be used to name variables, functions, etc. In general, it is recommended to use descriptive words or phrases to better understand the code.

In addition to reserved keywords, there are some special global properties and methods in JavaScript that you also need to pay attention to. For example, the global object window, global variable undefined, global function eval, etc. need to pay attention to their special properties when using them.

In general, reserved keywords are an important part of JavaScript syntax and have mandatory restrictions. Careful inspection is required before use to avoid errors. At the same time, you also need to master the functions and meanings of keywords in order to better understand and write complex JavaScript programs.

The above is the detailed content of What are the keywords of javascript. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!