Javascript accessing function of one js file into another
Javascript accessing function of one js file into another
by Mayank Vora
HTML
<div>Put below Separated code in two different js file</div>
<br/> <br/>
<div>
Simply Include these script file in Index.html and run index.html
</div>
JavaScript
/******** PUT THIS CODE IN ONE JS FILE *******/
var secondFileFuntion = function(){
this.property1 = 'First Property from different js file';
}
secondFileFuntion.prototype.getSecondProperty = function(){
return 'Second Property from different js file';
}
var secondFileObject = new secondFileFuntion();
/******** Till Here *******/
/******** PUT THIS CODE IN SECOND JS FILE *******/
function firstFileFunction(){
var name = secondFileObject.property1;
var surname = secondFileObject.getSecondProperty()
alert(name);
alert(surname );
}
firstFileFunction();