function getJSPassedVars(script_name, varName) {
var scripts = $('script'),
res = null;
$.each(scripts, function() {
var src = this.src;
if(src.indexOf(script_name) >= 0) {
varName = varName.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
var string = new RegExp("[\\?&]"+ varName +"=([^&#]*)"),
args = string.exec(src);
if(!args.length) {
res = null;
} else {
res = args[1];
}
}
});
return res;
}
console.log(getJSPassedVars('script-starter.js', 'var'));
in my case my app folder structure is like following:
MyApp/
index.html
jquery.js
my.js
above function is within my.js
with console.log
and include it within index.html
.