Best way to compare two lists of objects

I am trying to figure out the most efficient way (lowest execution time) to filter two lists of objects, keeping only a sublist of list A whose objects are not in list B.

One list is coming form an external API and the other list is coming from my Backendless DB.

The way I am doing it now is creating two lists of strings using the map block,

then using the filter block.

Is there a way with fewer steps where I can simply use the filter block on a list of objects and it will return the objects that do not appear with identical properties in the other list?

Another alternative is to have only the filter block and instead of using the list [] contains item iterate over the items in the internalWeeklySlots list. This can be done in a function.

So, for every object of externalWeeklySlots that passes through the filter block, I would check if a property of that object equals a property of any object in internalWeeklySlots?

Is there any way to check that an object contained in the internalWeeklySlots list, is also contained in the externalWeeklySlots list (same collection of properties)?

For example, if the object { “color”: “red”, “shape”:“round”, “name”:“apple”} were in both lists, the best way to find that is by filtering one list and checking if one or more of the properties of objects in the second list match? There is no way to check that there is an object that contains the same collection of properties?

No worries either way. Just making sure I am using the optimal solution.

yes

Only by iterating through the first list and checking each object individually.

I think I don’t know how to check an object individually, The below is false.

Is there a way to compare objects? Sorry if this is a silly question.

That’s correct, two objects that look identical (i.e. have the same properties with the same values) are not equal in the Codeless (technically the JS) world.

A workaround is to transform the objects to JSON (i.e. a string). As a result, we get the following:

This will printfalse:
UI Builder - ConsoleDemo - Backendless 2022-01-09 17-42-21

This will print true:

Regards,
Mark

Makes sense, thanks!