DEV Community

Discussion on: Generating Random Whole numbers in JavaScript in a specific range

Collapse
 
jonrandy profile image
Jon Randy 🎖️ • Edited

~ is the bitwise NOT operator, which will reverse all bits in the number - having converted it to a 32-bit signed integer first. Applying it twice resets the bits to their original state. It's a dirty trick to convert to an integer

w3schools.com/js/js_bitwise.asp