bitmask

A number used as a row of on/off switches, where each binary digit (bit) stands for one flag.

In more detail

Bitwise operators combine and test flags quickly: | adds a flag, & ~flag removes it, and x & -x keeps only the lowest set bit. Many flags fit in one number and can be compared in a single operation.

Examples

React stores pending update priorities as a lanes bitmask: pending |= SyncLane.
const SyncLane = 0b0001; pending |= SyncLane;

Related terms

Taught in

References