The !! construct is a simple way of turning any JavaScript expression into
its Boolean equivalent. For example: !!"he shot me down" === true and !!0 ===
false . In listing 4.8 we end up converting a function into its Boolean equiva-
lent, which will always be true . (Sure we could have hardcoded true , but then
we wouldn’t have had a chance to introduce !! ).
Тег js в блоге unam3
интересно, что мешало присвоить ф-ю и отдельно вернуть true
add: function(fn) {
if (!fn.id) {
fn.id = store.nextId++;
return !!(store.cache[fn.id] = fn);
}
}