Concrete implementation of a singly linked list node.

Provides forward-only node linking capabilities.

// Create nodes and link them
const node1 = new SinglyLinkedListNode();
const node2 = new SinglyLinkedListNode();
const node3 = new SinglyLinkedListNode();

node1.next = node2;
node2.next = node3;

Hierarchy (View Summary, Expand)

Implements

Constructors

Properties

Methods

Constructors

Properties

next: null | SinglyLinkedListNode = null

The next node, or null if the node has no next connection.

Methods

  • Detaches the node by updating the next reference of the previous node. After detachment, the node's next pointer is set to null.

    Parameters

    • previous: null | SinglyLinkedListNode

      The previous node, or null if the node has no previous connection.

    Returns void

    // Create a chain of nodes
    const node1 = new SinglyLinkedListNode();
    const node2 = new SinglyLinkedListNode();
    const node3 = new SinglyLinkedListNode();

    node1.next = node2;
    node2.next = node3;

    // Detach node2 from the chain
    node2.detach(node1);
    // Result:
    // node1 -> node3
    // node2.next === null
MMNEPVFCICPMFPCPTTAAATR