How to remove duplicates from multidimensional array? [closed]
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I have a multidimensional array: [[7,3], [7,3], [3,8], [7,3], [7,3], [1,2]] Is there any smart way to remove duplicated elements from this? It should return such array: [[7,3], [3,8], [1,2]] Thanks! 回答1: arr = [[7,3], [7,3], [3,8], [7,3], [7,3], [1,2]]; function multiDimensionalUnique(arr) { var uniques = []; var itemsFound = {}; for(var i = 0, l = arr.length; i Explaination: Like you had mentioned, the other question only dealt with single dimension arrays.. which you can find via indexOf. That makes it easy. Multidimensional arrays are not