html5 - Reading a javascript variable containing a string into another file -
for example in 1 file
test.js
var test = { string: "test string" };
i want read in js file this:
test.string should give me "test string" output.
any ideas good. thanks
modifying question bit:
i not able read global variable declared in same file.
var test = { string: "test string" };
is in same file.
how using in variable.
"mytest":{ "prop":{ myvar: "test.string" } }
so trying print mytest.prop.myvar , expecting "test string" giving test.string output
i'm not sure understood correctly: once have javascript file loaded, if variable declared in global namespace becomes available other scripts, long load them in correct order. in case have include <script src="test.js"></script>
load second file <script src="secondfile.js"></script>
in secondfile.js can use test.string normal.
update after update: have declared variable : instead of = meant probably
var mytest = { prop : { myvar : 'test.string' } };
now can use mytest.prop.myvar
Comments
Post a Comment