function ok(value, message) {
if (!!!value) fail(value, true, message, '==', assert.ok);
}
assert.ok = ok;
!!!value basically means not not not Boolean(value) yes?
Say if value = 9 > 1, then it would mean: not not not true.
not true = false
not not true = true
not not not true = false
My brain hurts. Why don't they just use !value instead of !!!value?
!value and !!!value both do have the same effect.
But, they intenionally use !! to convert the potential 'truthy' or 'falsy' variable value to a boolean.
So it does makes sense to use !!! when using value as a negated boolean, so developers can see that (in this case) value may only be 'truthy', e.g. a string and not true.
If in refactoring someone needs to set something to true and uses value, it may be set to a string. The !!! tells him to use !!value, if he expects value as a boolean.
The likely answer is either that they're using it to draw emphasis to the conversion or that some programmer just thought it was funny at some point -- there's absolutely no syntactical difference between !x and !!!x (or !!!!!!!!!!!!!x for that matter). After the first ! which will convert the variable to a boolean, you're just repeatedly adding the not operator to something. All that matters is whether it's negated an even or odd number of times.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With