Why does Node.js' Assert.js use !!!value in their code? What purpose does it serve?

geoyws
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?

user3653148

!! is Cast or Convert the variable to Boolean and the additional ! inverts it. I think you could do this if it's easier to read var invertedBool = !Boolean("false");

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

Related Related

HotTag

Archive