0

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?

Kayce Basques
  • 17,419
  • 7
  • 71
  • 96

1 Answers1

0

The double exclamation mark forces a truthy/falsey value into a boolean. Think of it like !(!useCapture), or not (not use Capture).

iampueroo
  • 71
  • 1
  • 6