JavaScript - Keywords

Here are some common keywords in JavaScript:

  •  
  • var: used to declare variables in JavaScript. It has function-level scope and its value can be changed within the function.
  • let: used to declare variables in JavaScript with block-level scope. The value of a let variable can be changed within its scope.
  • const: used to declare variables in JavaScript with block-level scope that cannot be changed.
  • function: used to declare a function in JavaScript. Functions are reusable blocks of code that can be executed when called.
  • return: used to return a value from a function. The code execution will exit the function and return the specified value.
  • if: used to perform conditional logic in JavaScript. If the condition specified in the if statement is true, the code block within the if statement will be executed.
  • else: used in conjunction with if statement to provide an alternative code block to be executed if the if condition is false.
  • switch: used to perform multiple conditional operations. A switch statement compares the value of an expression with multiple case labels, and the code block associated with the first matching case label will be executed.
  • while: used to repeat a block of code while a specified condition is true. The code block will be executed repeatedly until the condition becomes false.
  • for: used to repeat a block of code a specified number of times. The for loop is often used to iterate over arrays and objects.
  • this: refers to the object that is executing the current function. The value of this can change based on how the function is called.
  • new: used to create an instance of an object in JavaScript. When used with a constructor function, the new operator creates a new object and sets the value of this to the new object within the constructor function.
  • try: used to handle exceptions and errors in JavaScript. A try block contains code that might throw an exception, and the associated catch block contains the code to be executed in case an exception is thrown.
  • instanceof: used to check if an object is an instance of a specified object type. It returns true if the object is an instance of the specified type, and false otherwise.
  • typeof: used to check the data type of a variable in JavaScript. It returns a string indicating the type of the variable.
  • delete: used to delete a property from an object in JavaScript. When used with an object property, it deletes the property and its value.
  • void: used to evaluate an expression and return undefined. It is often used to evaluate expressions for their side effects without using their returned value.