Tareq Al-Zubaidi
1 min readMar 7, 2019

--

There is other simple and more performant solution for this problem.

I would use recursion to solve this.

const clone = (items) => items.map(item => Array.isArray(item) ? clone(item) : item);

See comparison test here

--

--