I'm studying the TodoMVC source and came across this helper:
// addEventListener wrapper:
window.$on = function (target, type, callback, useCapture) {
target.addEventListener(type, callback, !!useCapture);
};
What's up with !!useCapture
?
I'm studying the TodoMVC source and came across this helper:
// addEventListener wrapper:
window.$on = function (target, type, callback, useCapture) {
target.addEventListener(type, callback, !!useCapture);
};
What's up with !!useCapture
?
The double exclamation mark forces a truthy/falsey value into a boolean. Think of it like !(!useCapture)
, or not (not use Capture).