Nodes and linked lists
Read · 1 of 3
A node knows the next node
A linked list is a chain of nodes. Each node holds a value and a reference to the next node; the last one's next is null.
To visit every value, start at the head and keep following .next until you reach null.
1class Node {2 constructor(val) {3 this.val = val;4 this.next = null;5 }6}