I'd recommend to refactor the following, but I did not know whether you had a good reason for them.
Checks for undefined
You often do checks for undefined values like this:
if (listeners[key] === undefined) {
return;
}
Is there a specific reason why you soecifically check for undefined and not for truthyness/falsyness?
if (!listeners[key]) {
return;
}
const self = this
Each function has a self variable to save the this context of the function – fair enough!
However, this would not be necessary if you used arrow functions all the way for the inner functions.
Is there a reason why you chose to do so?
let
andconst
and avoid evilvar
Open questions
I'd recommend to refactor the following, but I did not know whether you had a good reason for them.
Checks for
undefined
You often do checks for
undefined
values like this:Is there a specific reason why you soecifically check for
undefined
and not for truthyness/falsyness?const self = this
Each function has a
self
variable to save thethis
context of the function – fair enough! However, this would not be necessary if you used arrow functions all the way for the inner functions. Is there a reason why you chose to do so?