How to pass parameters / arguments from one javascript snippet to another, when evaluated <p>My goal is to execute a javascript snippet using another javascript snippet using </p> <p><code>new Function(x1, x2, x3, functionBody)</code> call.</p> <p>My problem appears when i need to pass parameters to the function, this is because functionBody may appear as a new Js script with global declarations and calls. </p> <pre><code>function main() { var a = x1; var b = x2; var c = x3; .... .... } main(); // this is the function that starts the flow of the secondary Js snippets </code></pre> <p><strong>Edit:</strong> I have a script responsible for downloading and executing another Js script. each downloaded script is executed by a global call to main(), which is unknown to the caller script.</p>