You need to have a global variable. Ok. But you are worried that it will clash with someone elses global name? After all the quantity of javascript behind www pages this days is exponentially rising. It is almost certain that any “normal” name is already there in the global javascript space.
This might be your solution. Use unicode in variable names. Here is a perfectly legal javascript:
Here we have one global array with somewhat crazy name. I am sure you will agree it is very remotely possible someone else (one day) will produce javascript with the global named exactly like the one above.
To use the name above in your code, you do not need to copy and paste the funny character. You can use the ‘\u notation’.
1 2 3 |
\u1234 = [1,2,3] ; \u1234[0] = "new entry for index 0" ; // legal javascript |