That is to make this:
[ [\'dog\',\'cat\', [\'chicken\', \'bear\'] ],[\'mouse\',\'horse\'] ]
into:
[\'dog\',\'cat\',\'chicken\',\'
Now in 2019 you can easily use Array.flat with whatever depth you want.
let arr = [ ['dog','cat', ['chicken', 'bear'] ],['mouse','horse'] ]
let op = arr.flat(Infinity)
console.log(op)
Now if you want to get unique values you can combine both Set and flat
let arr = [ ['dog','cat', ['chicken', 'bear', 'cat'] ],['mouse','horse', 'dog'], [[[['deeper','chicken']]]] ]
let unique = [...new Set(arr.flat(Infinity))]
console.log(unique)