Scenario: I am developing a chrome extension and I have a bunch of listeners I need to add in the foreground.
What I would like to do: create an object named 'listeners' containing only functions (functions that will run addListeners), and a function called 'init' that would iterate my 'listeners' object and dynamically execute every function.
Why: I would like to add new listeners to the object without worrying about having to call them directly one by one in my init function. I know it would not be too much of a hassle doing so but it would be interesting if I could make the thing more dynamic.
Is this possible?
Something like:
const listeners = {
    func1: function (){...},
    func2: function (){...},
    func3: function (){...}
}
function init(){
    for (let func in listeners){
        //somehow execute func
        //func() appearently does not work
        //()=>func appearently does not work
    }
}
init();
 
     
     
     
    