Created
November 15, 2020 07:49
-
-
Save ashwinkumar2438/89389f366d2df6677da8d7b2d0a75d12 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
on(eventname,callback){ | |
if(!eventname)return false; | |
if(!(callback && callback.constructor===Function))return false; | |
if(!this[eventname]){ | |
this[eventname]=[]; | |
} | |
if(!this[eventname].includes(callback) && Array.isArray(this[eventname]) && this.hasOwnProperty(eventname)){ | |
this[eventname].push(callback); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment