Uniquify a two dimensional array

October 02, 2017

Use the following function to get non-duplicate version of a two-dimensional​ array

const unique = (arr) => {
  let map = {}
  return arr.filter(item => {
    if (item in map) return false
    else {
      map[item] = true
      return true
    }
  })
}

uique([[1,2], [1,2]]) 
//=> [[1,2]]

Tagged withjavascript, array

Questions, Comments, Suggestions? Open an Issue