0

I have a list that has many function with parameter.How can i loop in list and invoke all of the functions in the list?

 list= [];

and then i push many function in individualWidgetList;

 list.push(loadPhoneWidget);
 list.push(loadEmailWidget);
 list.push(loadAgentWidget);
 list.push(loadClientWidget);

now i want invoke the functions

 for (var i = 0; i < individualWidgetList.length; i++) {

   invoke here    
 }

2 Answers 2

1

Do it like this :

 for (var i = 0; i < individualWidgetList.length; i++) {
     individualWidgetList[i](myParameters);
 }
Sign up to request clarification or add additional context in comments.

Comments

0

Assuming the objects in the list are functions.

 for (var i = 0; i < individualWidgetList.length; i++) {
   individualWidgetList[i](/*Any Parameters*/);    
 }

1 Comment

@Cerbrus your one step ahead of me

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.