Keywords in JavaScript

  • Keywords in JavaScript are reserved words that have a specific meaning and purpose within the language. They are predefined and cannot be used as variable names or function names, and attempting to do so will result in a syntax error.
Here are the current list of JavaScript keywords:
  • break: Used to terminate a loop or switch statement
  • case: Used to define a case clause in a switch statement
  • catch: Used to handle errors in a try-catch block
  • class: Used to define a class in JavaScript
  • const: Used to define a variable that cannot be reassigned
  • continue: Used to skip to the next iteration of a loop
  • debugger: Used to halt the execution of code and launch the debugger
  • default: Used to define the default case in a switch statement
  • delete: Used to delete a property from an object
  • do: Used to define a do-while loop
  • else: Used to define the alternative path in an if-else statement
  • export: Used to export a module or function from a module
  • extends: Used to inherit from a parent class in a class definition
  • false: Boolean literal representing the false value
  • finally: Used to define a block of code to execute after a try-catch block
  • for: Used to define a for loop
  • function: Used to define a function
  • if: Used to define a conditional statement
  • import: Used to import a module or function from a module
  • in: Used to check if a property exists in an object
  • instanceof: Used to check if an object is an instance of a particular class
  • let: Used to define a block-scoped variable that can be reassigned
  • new: Used to create a new instance of an object or class
  • null: Represents the null value
  • return: Used to return a value from a function
  • super: Used to call a method on a parent class in a class definition
  • switch: Used to define a switch statement
  • this: Refers to the current object in a method or constructor
  • throw: Used to throw an error
  • true: Boolean literal representing the true value
  • try: Used to define a try-catch block
  • typeof: Used to get the type of a variable or expression
  • var: Used to define a variable that can be reassigned or redeclared
  • void: Used to evaluate an expression and return undefined
  • while: Used to define a while loop
  • with: Used to create a new scope for an object
  • It's important to note that some keywords, such as let and const, were introduced in newer versions of JavaScript and may not be supported in older browsers.

No comments:

Post a Comment

Primitive Types in TypeScript

In TypeScript, primitive types are the most basic data types, and they are the building blocks for handling data. They correspond to simple ...