4
I wanted to call a Function of a Javascript in another Javascript file.
For example, in the file compute js., i have the Function sum(a,b). And I needed to call this Function in the file js calculator. (for example).
I wondered if it is possible this communication between two or more js files. And how could it be done?
Correct. But you don’t need to explicitly write
window.somar
.var somar = function(a,b)
orfunction somar(a, b)
also work.– Beterraba
No need to inform window if you are in the global scope of a single document
– gpupo
@Beet Yes, but let’s say that this is the most "safe" way, because if you declare this function within the scope of another, it does not become visible (if you are using this approach, for example).
– user7261
And guys, thanks for the help, it helps me a lot. Thank you.
– Erico Souza