Clears (sets to 0) the bit at the specified position in a number.
The original number is not mutated; a new number is returned with the bit cleared.
A new number equal to n with bit k cleared.
n
k
clearBit(0b1011, 1); // → 0b1001 (clears bit 1)clearBit(0b1111, 3); // → 0b0111 (clears bit 3)
The original number whose bit is to be cleared.
Zero-based bit position to clear (0 = least-significant bit).
Generated using TypeDoc
Clears (sets to 0) the bit at the specified position in a number.
The original number is not mutated; a new number is returned with the bit cleared.
Returns
A new number equal to
nwith bitkcleared.Example
Remarks
kis affected; all other bits remain unchanged.