How to pass parameters in eval in an object form?
How to pass parameters in eval in an object form?
http://stackoverflow.com/questions/1500745/how-to-pass-parameters-in-eval-in-an-object-form
I have this json, and when i get this json i need to run the function which comes at callback object.
so according to this i need to run this:
i can do that with eval function like:
i can automate this by putting it into a for in and writing parameters to a string, but i dont think this is the best way to go. is there a way to assign function name from a var and giving its parameters as an object, in my case like:
i know this is not the way to do it but it is what i want to learn. Thanks, Sinan. |
|||||
|
Depends on where the function to call is defined (global scope or a local scope). If global, you don't need
See the If it's in a local scope, then you need the |
|||||
|
Don't use eval. You can get a reference to a named global variable or function from the
And trying to serialise your values to a string just to have them parsed back to JavaScript unreliably is silly. Call the function explicitly:
( Better for automating it to accept any number of parameters would be to turn callbackParams into a plain Array:
and then use
|
|||||
|