Concepts

FIFO circular queue

Try the free JavaScript compiler

First-in-first-out abstract data type. A fixed-capacity ring buffer tracks occupancy and wraps indices without shifting the remaining values.

Formal Syntax & Structure

javascript syntaxjavascript
enqueue(value); dequeue(); tail = (head + size) % capacity

Working Example

Example Snippetjavascript
const q=["A","B","C"];let head=0;console.log(q[head++],q[head++],q[head],q.length-head);
JavaScript Reference