Great advice! But how can we consider objects as duplicates even if they have same properties when they are passed by reference. So I think objects case is not applicable to this problem.
If you considered these objects duplicates [{id:1}, {id:1}], the Set approach won't suit. In this case though you'd probably need to use a utility library like Lodash: _.uniqWith(objects, _.isEqual)
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Great advice! But how can we consider objects as duplicates even if they have same properties when they are passed by reference. So I think objects case is not applicable to this problem.
If you considered these objects duplicates
[{id:1}, {id:1}]
, the Set approach won't suit. In this case though you'd probably need to use a utility library like Lodash:_.uniqWith(objects, _.isEqual)