I think I know the answer but... is there any way to prevent a global variable from being modified by later-executing ? I know global variables ar
You might want to try out this jquery plugin. It prevents you to create global objects in javascript :)
Store data
// 'val' can be a string, integer, hash table, array, object
$.secret( 'in', 'secretName', val );
// or a function
$.secret( 'in', 'secretName', function( arg1, arg2, arg3 ){
// do something here
});
Use data; you can even use it in different files.
var lang = $.secret( 'out', 'lang' );
Call out a function
$.secret( 'call', 'secretName', [ arg1, arg2, arg3 ]);
// or
$.secret( 'call', 'secretName', arg );
Clear data
$.secret( 'clear', 'lang' );
source code is on github