What does the !! (double exclamation mark) operator do in JavaScript?
@lebyy▲ 0 net votes
Problem: I saw this code: this.vertical = vertical !== undefined ? !!vertical : this.vertical; It seems to be using !! as an operator, which I don't recognize. What does it do? Fix (from the top answer): It converts Object to boolean . If it was falsy (e.g., 0 , null , undefined , etc.), it would be false , otherwise, true . !object // Inverted Boolean !!object // Noninverted Boolean, so true Boolean representation So !! is not an operator; it's just the ! operator twice. It is generally simpler to do:…