What does the “|” (single pipe) do in JavaScript?

This is a bitwise or.
Since bitwise operations only make sense on integers, 0.5 is truncated.

x | 0 is x, if x is an integer.

Leave a Comment