Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

173
Vistas
Is Node a predefined class in Node.js?

I am learning Linear Data Structures in JavaScript via Codecademy and in lesson's introduction it states:

We are going to use a provided Node class, which you can find in Node.js.

The code in their built-in IDE is as follows:

const Node = require('./Node');

class LinkedList {
  
}

module.exports = LinkedList;

When you look at the Node.js file referenced in require, there is a Node class defined like so:

class Node {
  constructor(data) {
    this.data = data;
    this.next = null;
  }

  setNextNode(node) {
    if (!(node instanceof Node)) {
      throw new Error('Next node must be a member of the Node class');
    }
    this.next = node;
  }

  getNextNode() {
    return this.next;
  }
}

module.exports = Node;

So basically, does this already exist in a Node.js module to avoid having to access them all for this lesson, or did they create a custom class named Node?

about 4 years ago · Santiago Gelvez
1 Respuestas
Responde la pregunta

0

The require('./Node'); indicates where the dependency came from.

I would recommend https://nodejs.dev/learn/nodejs-file-paths for more info on file path access.

As provided in your example, it seems that the file (Node.js) can be found in the project's root directory, and it is 100% their implementation of the Node class as Node.js does not provide 'default' classes and implementations.

If you cannot use the same project as they did, then I suppose you will not have access to the Node class. You can make such folder structures; to have a shared folder library along with other folders per class/lesson, which will inject/require such shared dependencies.

about 4 years ago · Santiago Gelvez Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda