That is to make this:
[ [\'dog\',\'cat\', [\'chicken\', \'bear\'] ],[\'mouse\',\'horse\'] ]
into:
[\'dog\',\'cat\',\'chicken\',\'
What about this one liner code ?
console.log([['dog', 'cat', ['chicken', 'bear']], [['mouse', 'horse'], 'lion']].join().split(','));
basically join will make comma separated string from nested array and using split you can get 1d array, nice ? bonus it'll work on all major browsers as well :)