Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

171
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda