The easiest way of flattening the Objects of any depth would be using the flat method
var arr = [['dog','cat', ['chicken', 'bear']],[['mouse','horse'],'lion'] ];
var flattened = arr.flat(Infinity);
//output--> ["dog", "cat", "chicken", "bear", "mouse", "horse", "lion"]
More aout Flat()