Related: https://stackoverflow.com/questions/784929/what-is-the-not-not-operator-in-javascript When used as a conditional, there is no logical difference.
– Alex WayneOct 28 '20 at 18:10
1
Since the question is 'what is the difference', then that would be two extra explicit operations (!!) vs the first version which just does the truthy check.
– TaplarOct 28 '20 at 18:12
1
@Taplar, Depends. A smart compiler could optimize the double-negation away.
– ikegamiOct 28 '20 at 18:13
!! is used to normalize a "truthy" value into true or false. There's no point in doing this here. if is just as capable of evaluating the truth of the value as ! is.