callback - How can I call javascript function using a foreach on a JSON object? -


my problem pretty easy understand. have json object (see code) , automatically call functions of object in order appears.
.

var installer = {     : function() {           ...         }     b : function() {           ...         } };  for(var func in installer) {     fn.call(document); }; 

have idea why previous code doesn't work ? i'm sorry, i'm beginner in javascript.

thanks in advance !

regards.

you declare var func variable loop through members of installer, yet use fn.call(...). did fn come from?

should able do: installer[func].call(document) instead of fn.call(document).

also functions declared in installer object don't take arguments, yet you're passing document argument.

[updated code add missing .call installer[func](document)]


Comments

Popular posts from this blog

python - Scipy curvefit RuntimeError:Optimal parameters not found: Number of calls to function has reached maxfev = 1000 -

c# - How to add a new treeview at the selected node? -

java - netbeans "Please wait - classpath scanning in progress..." -