Garmaine Staff asked 1 year ago
This question already has answers here:
http://stackoverflow.com//questions/784929/what-is-the-not-not-operator-in-javascript”>What is the !! (not not) operator in JavaScript? (36 answers)
Closed 6 hours ago.

Can someone point me in the way towards some documentation as to what it means to use !!. I have a return statement

return !! _.reduce(collection, function(a, b){
  // a is a result of last call
  // b is result of calling iterator on current value
  console.log("a: "+a)
  console.log("b: "+b)
  console.log(iterator(b));
  //will return false or true based on test
     return a && iterator(b);
    }, true)
}

which works but this doesn't

return  _.reduce(collection, function(a, b){
  // a is a result of last call
  // b is result of calling iterator on current value
  console.log("a: "+a)
  console.log("b: "+b)
  console.log(iterator(b));
  //will return false or true based on test
     return a && iterator(b);
    }, true)
}