I have following code:
window.$(".my-class").datepicker({
    ...
    onSelect: function() {
        var event = new CustomEvent("input", {});
        this.dispatchEvent(event);
    },
    ...
and it works. But once I change the function to arrow function
window.$(".my-class").datepicker({
    ...
    onSelect: () => {
        var event = new CustomEvent("input", {});
        this.dispatchEvent(event);
    },
    ...
i get error on this saying it doesn't have param dispatchEvent. Why my arrow function has different this?
 
    