What does ! do in JavaScript?

I’ve been working with JavaScript for a while, and the !! operator is one of those handy little tricks I use often. Essentially, !! converts any value to a boolean.

The first ! flips the truthiness (true becomes false, false becomes true), and the second ! flips it back—resulting in a strict true or false. So in your code, !!vertical ensures that vertical is a boolean, not just a truthy or falsy value. It’s super useful when you want a clean boolean flag.