How to use the spread operator to flatten array of objects in javascript
How to use the spread operator to flatten array of objects in javascript
function flatten(arr) { while (arr.some((item) => Array.isArray(item))) { arr = [].concat(...arr) } return arr } let arr = [1, 2, [3, 4], [5, [6, 7]]] console.log(flatten(arr))
Có thể bạn đã miss một số snippets code