NodeJS Keywords: What Are Reserved Keywords in NodeJS?

Keywords are reserved words, which can’t be used as a variable, label, or function name. The keywords have their operation and perform in a certain way to provide different functionality.

Most Common NodeJS Keywords

There are many keywords in Node.js, and in order to understand the fundamental of Node.js, it is important to learn about the most used keywords in detail.

var keyword

This is a keyword used to create variables in Node.js. The scope of this keyword is global or function scope, which means you can call it anywhere inside the function in which it is declared, or you call it anywhere if it is declared outside the function.


var name = value;

let keyword

This keyword is the same as var, but the scope of this function is block-scope. It can not access outside a block in which it is declared.


let name = value;

const keyword

This keyword is used to create a constant whose value can not be changed unlike var and let. The scope of this function also blocks scope.


const name = value;

if/else keyword

If the else keyword is used to execute the statements on the basis of a condition, if the condition is true it will execute the expression in the if block, otherwise executes the statements in the else block.


    // statements 
    // statements 

for/while/do keyword

These are the keyword used for creating loops which are used to execute the statements many times under some conditions.

We’ve covered NodeJS Loops in another article if you want to learn more about them.

function keyword

This keyword is used to create functions in Node.js.


function function_name(parameters){
    // statements 

Also read: NodeJS Functions: A Beginner’s Introduction

async/await keyword

Await is used before a statement to hold on and wait for a promise to return. For using await inside a function, it is important to use the async keyword just before the function keyword.


async function name(parameters) {
  await promise

try/catch/finally keyword

These keywords are used to catch errors. If there is no error, only the try block will execute but, if there are some errors then the statements inside the catch block are executed. You can optionally add the “finally” block which is executed every time after the try or catch blocks are executed. Consider finally as the last thing that the try-catch blog must do before exiting.


try {
} catch (exceptionVar) {
} finally {

then keyword

This keyword works with promise, it uses to return a promise and for method chaining.


const promise1 = new Promise((resolve, reject) => {

promise1.then((value) => {
  // expected output: "Success!"

export keyword

This keyword is used to export a function or module in Node.js so that it can be used in some other files.


export function_name

require keyword

This keyword is used to import a function or module in Node.js.



throw keyword

This keyword is used to create a custom error which helps in debugging.


throw statement

class keyword

This keyword is used to create a class in Node.js.


class class_name {

super keyword

This keyword is used to call the constructor function of the parent class to access its properties and methods.



this keyword

This keyword is used to call global objects, variables, or functions.




Keywords are reserve words which means they can’t be used for creating variables, constants, functions, etc. It is important to learn about keywords to master the fundamental of Node.js. We hope this tutorial helped you understand the keywords of Node.js.


Aditya Gupta
Aditya Gupta
Articles: 107