!! (Double-Not Operator)

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) {
return collection.reduce(function(prev, item) {
return !!prev || predicate(item);
});
};
Show your support

Clapping shows how much you appreciated Ryo Osawa’s story.