Created
April 13, 2019 13:24
-
-
Save fractalliter/1c0d923fd011a8fc525c40681de3b28d to your computer and use it in GitHub Desktop.
Emitter
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
const emitter = (object, property) => Object.keys(object).find(item => item === property.toString()) ? object[property].map(item => item()): console.log("No match found"); | |
const myInfo = { | |
name: [()=>console.log("My name is Elias"), () => console.log("I am Developer")], | |
fname: [() => console.log("My family name is Rahmani")], | |
age: [() => console.log(`I am ${30}`)] | |
}; | |
emitter(myInfo, "name"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment