JavaScript Keywords

In JavaScript, a keyword is a reserved word define by the JavaScript developer, with its pre-defined meaning. For example:

HTML with JavaScript Code
<!DOCTYPE html>
<html>
<body>

   <p id="xyz"></p>
   
   <script>
      var x = 10;
      if(x == 0) {
         document.getElementById("xyz").innerHTML = "The value of 'x' is equal to 0.";
      }
      else if(x > 0) {
         document.getElementById("xyz").innerHTML = "The value of 'x' is a positive number.";
      }
      else {
         document.getElementById("xyz").innerHTML = "The value of 'x' is a negative number.";
      }
   </script>
   
</body>
</html>
Output

In above example, the var, if, and else are keywords. The var is used to declare a variable. The if is used when we need to execute some block of code, when the specified condition evaluates to be true. The else is the counter-part of if.

Note - Do not use any keyword as an identifier. If you do so, then that word acts the way, it is defined by the developer. So avoid using any keyword listed in this article.

List of All Keywords in JavaScript

Here are the list of all keywords available in JavaScript:

JavaScript Online Test


« Previous Tutorial Next Tutorial »