Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

js import

//A function cannot be called unless it was defined in the same file or one loaded before the attempt to call it.
//A function cannot be called unless it is in *the same or greater scope* than the one trying to call it.
//You declare function fn1() in First.js, and then in Second.js you can just call fn1();
//In this case, you need to make sure that First.js and Second.js are in the same folder, or that First's folder is of a higher hierarchy than Second's.

//First.js
function fn1() {
	alert();
}

//Second.js
function foo() {
	fn1();
}
Source by appdividend.com #
 
PREVIOUS NEXT
Tagged: #js #import
ADD COMMENT
Topic
Name
1+1 =