Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

170
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!