var a = new Array(); var b = new Array(); var c = [a,b]; var str = 'hello,world,nice,day'; for(var i = 0; i < c.length; i++){ c[i] = str.split(','); }
After execution, I would like to have:
c = [a, b]; a = ['hello', 'world', 'nice', 'day']; b = ['hello', 'world', 'nice', 'day'];
but actually i have:
c = [['hello', 'world', 'nice', 'day'], ['hello', 'world', 'nice', 'day']]; a = []; b = [];
Can i fix it?
UPD: Raynos solution is really nice. thanks.
FSou1 source share