All background scripts use the same JS context, so any variable / function declared in one of the scripts is accessible to everyone else (the loading order plays a role).
Chrome HTML- <script> . . :
<html>
<head></head>
<body>
<script src="common.js"></script>
<script src="example.js"></script>
<script src="extjs.js"></script>
</body>
</html>
, chrome://extensions Developer mode. " ", , DevTools .
UPDATE:
, - ( trial()) ( ).
var result trial(), . (, example.js.)
:
example.js:
var outer_result = 0;
function trial() {
var inner_result = 1;
outer_result = 2;
}
extjs.js:
console.log(outer_result); // <-- '0' since `trial()` is not invoked yet
console.log(inner_result); // <-- 'undefined' since it is never defined
trial(); // <-- executing `trial()` function
console.log(inner_result); // <-- 'undefined' since it is function-local
console.log(outer_result); // <-- '2' since `trial()` modified it