I'm trying to remove duplicate values in an array. As I was searching I found that I could use .filter() for the solution. Following code seems to work, but I don't understand how return array.indexOf( value ) === index;
part works. Can someone explain what that part mean? So far I understand that .filter() returns values that is true.
var items = [3,2,2,4,8,8,8,6,9];
var result = items.filter( function( value, index, array ) {
return array.indexOf( value ) === index;
})
console.log( result );