Concepts

Singly linked list

Try the free JavaScript compiler

Linked nodes represent ordered data; local link changes are constant work once the relevant node is known, but locating it may require linear traversal.

Formal Syntax & Structure

javascript syntaxjavascript
node = { value, next }; head = { value, next: head };

Working Example

Example Snippetjavascript
let head=null;for(const value of [3,2,1])head={value,next:head};const out=[];for(let node=head;node!==null;node=node.next)out.push(node.value);console.log(JSON.stringify(out));
JavaScript Reference