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
  • 23,849
  • 11
  • 86
  • 120

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
  • 121
  • 2
  • 6