Javascript External - Array Function

What is external array?

Explanation

External Array is used to load the array from external js file and result will be displayed in another file.
Example Code:
example.js:
var testArray=new Array();
testArray= ["PHP","Javascript","Jquery","JSP","CSS"];


example.html:
<script type='text/javascript' src='example.js'></script>
<script type='text/javascript'>
$(document).ready(function ()
{
document.write(testArray[0]);
});
</script>


Result:


PHP


Thus, external array can be loaded from external js file 'example.js'. The result will be displayed in example.html file.

Ask Questions

Ask Question