How to use the spread operator to flatten array of objects in javascript

es6,spread_operator_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

jQuery on hover

Jquery on mouse over example.

Rest Operator for Objects

Now we can use rest on the properties of an Object. It allows us to explicitly extract certain named variables, and assign any uncalled variables into a catchall Object.

Getting the last element of a split string array

Getting the last element of a split string array

Remove array of objects from another array of objects

Remove array of objects from another array of objects

Đếm có bao nhiêu items giống nhau trong một array

reduce javascript. Đếm có bao nhiêu items giống nhau trong một array