!! (Double-Not Operator)
1 min readOct 1, 2014
I’ve been learning some cool Javascript tricks lately. Using two “!” operators to convert a truthy/falsy value into an actual Boolean type is one of my favorites so far. For example, you can use this trick and reduce function to implement every function.
var every = function(collection, predicate) {Get Ryo Osawa’s stories in your inbox
Join Medium for free to get updates from this writer.
return collection.reduce(function(prev, item) {
return !!prev || predicate(item);
});
};




