I am making some checking between array. It is in NodeJS.
The question is:
I have an array:
var items = [];
than I insert some values into it:
items[0] = {a:1, b:222};
items[1] = {a:1, b:333};
items[2] = {a:1, b:222};
items[3] = {a:1, b:4444};
items[4] = {a:1, b:222};
So, what I need to do is: to go threw all array and remove item's that has the same 'b' value.
Example:
After filtering, it should look like:
items[0] = {a:1, b:222};
items[1] = {a:1, b:333};
items[2] = {a:1, b:4444};
As you see elements with indexes 2 and 4 gone, because they has the same b value as element at index 0.
How can I write this little code in JavaScript?