How to filter duplicate sub-arrays of integers and strings from two dimensional array in Javascript -


i receiving 2-dimensional array of both integers , strings, , want remove duplicates them:

original array = [["admin", 2, "regular"], ["customer", "regular"], ["regular", "customer"], [1], ,["admin"], [1], ["admin"]

expected result = [["admin", 2, "regular"], ["customer", "regular"], [1], ["admin"]]

please how can in javascript?

does matter if array (and it's sub-arrays) gets reordered? if doesn't, then:

var array = [["admin", 2, "regular"], ["customer", "regular"], ["regular", "customer"], [1],["admin"], [1], ["admin"]];    array = array.map(x => x.sort()).sort();    var uniquearray = [];  uniquearray.push(array[0]);    (var = 1; < array.length; i++){    if (json.stringify(array[i]) != json.stringify(array[i-1])){        uniquearray.push(array[i]);        }  }    console.log(uniquearray);


Comments

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

Add new key value to json node in java -