I have this issue where i have 2 files
1) containing main() and other stuff related to the main UI
inside main() there are some functions
2) another file that makes the connection from the server to the UI
I am unable to find any solution to call functions from main() from the secondary file ( I know this is not a godd programming-design but i’ve already written a lot of code)
Thanks:)
In js,
functions are your scope constraints. So, consider the following code:Given your situation, you might consider returning some of main’s functions like this:
Here’s how you would do it with prototypes:
Here are a few jsfiddles so that you can play with these examples:
http://jsfiddle.net/lbstr/A3dSB/
http://jsfiddle.net/lbstr/FyDAL/
http://jsfiddle.net/lbstr/2TLu2/