Javascript - IE, Chrome, Firefox - How does working with external .js files work?

Say I have 3 files.

  • index.html (HTML + javascript)
  • somescript1.js (Javascript file)
  • somescript2.js (Javascript file)

Is it appropriate to consider javascript participating in all three files as "concatenated" together, so that they are long scripts with variables and functions available between all three?

If several functions with the same name are defined, is only the last one used? (For example, if I define a function at the end of the parent index.html, will it override the ones defined in the linked javascript files?)

Given the answer, I would like to know if it is the same between all three main browsers. I know that the above questions can be answered โ€œyesโ€ to at least one of the browsers, but I really want to be sure that I can look at this perspective for any large browser.

+3
source share
1 answer

Is it appropriate to consider javascript participating in all three files as "concatenated" together, so that they are long scripts with variables and functions available between all three?

. script, , , script. , script (, onload), .

, ? (, index.html, , javascript?)

( )

, .

( ).

+4

All Articles