Ralph a écrit :
Hi
Is this possible?
var c = 'bonjour';
function glob() {
var a = 'hello';
b = 'saluti';
}
glob();
alert(a); // undefined
alert(b); // saluti
alert(c); // bonjour
all variables in JS are global
except those declared in a function and prefixed with var
One thing I can do is create the global array
do you mean array of globals ?
and add the new item to it
from inside the function but that's not what I'm looking for.
function arr() {
tablo = new Array('one','two');
}
function arrAdd() {
if( typeof (tablo) == 'undefined') arr();
for(var i=0; i<arguments.length; i++)
tablo[tablo.length] = arguments[i];
}
arrAdd('three','for','five');
alert(tablo[4]); // five
--
ASM