On my desk

Identifiers in Node.js

Identifiers in Node.js are names used to refer to various entities, including variables, functions, classes, and modules. They help in accessing and manipulating data and functionality within application. Identifiers are essential for creating and managing different aspects of your codebase efficiently.

By Published Updated

Working log

1. Variables: Names for storing data

CODE SAMPLE Code snippet
const port = 3000; // Identifier: `port`
let server = require('http').createServer(); // Identifier: `server`

2. Functions: Names for functions

CODE SAMPLE Code snippet
function startServer() {} // Identifier: `startServer`

3. Classes: Names for classes used to create objects with specific properties and methods

CODE SAMPLE Code snippet
class User {
  constructor(name) {
    this.name = name;
  }
} // Identifier: `User`

4. Modules: Names for files or modules that are imported or required

CODE SAMPLE Code snippet
const fs = require('fs'); // Identifier: `fs`
const express = require('express'); // Identifier: `express`

5. Objects: Keys in objects act as identifiers for their corresponding values

CODE SAMPLE Code snippet
const config = {
  host: 'localhost', // Identifier: `host`
  port: 3000 // Identifier: `port`
};

6. Labels: Names used to label loops and control flow

CODE SAMPLE Code snippet
outerLoop: for (let i = 0; i < 5; i++) { // Identifier: `outerLoop`
  for (let j = 0; j < 5; j++) {
    if (j === 3) {
      break outerLoop; // Identifier: `outerLoop`
    }
  }
}