I have many objects from which I am trying to filter out duplicates. When an object has a property, IMAGEURL , which is present in another object, I want to ignore this object and move on.
I use nodeJS for this, so if there is a library that I can use to simplify it, let me know.
Earlier, I did similar implementations, checking string values ββin arrays, doing something like:
var arr = ['foo', 'bar']; if(arr.indexOf('foo') == -1){ arr.push('foo') }
But this will not work for objects, as far as I can tell. What are my options? Simply put:
var obj1 = {IMAGEURL: 'http://whatever.com/1'}; var obj2 = {IMAGEURL: 'http://whatever.com/2'}; var obj3 = {IMAGEURL: 'http://whatever.com/1'}; var arr = [obj1, obj2, obj3]; var uniqueArr = []; for (var i = 0; i<arr.length; i++){
How can i do this?
javascript object arrays for-loop
Jascination
source share