Javascript examples for Array Operation:Array Element
Filter unique element in array based on subarray property
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <script type="text/javascript"> window.onload=function(){/*from ww w . j a v a2 s . c o m*/ var arr = [ ["foo", "one"], ["baz", "two"], ["bar", "one"], ["baz", "two"], ["bar", "one"], ["qux", "two"] ]; var seenit = []; var n = arr.filter(function(it){ var result = seenit.indexOf(it[1]) === -1; seenit.push(it[1]); return result; }); console.log(n); } </script> </head> <body> </body> </html>