Removing object/array difference from different arrays [duplicate]
- by Kay Singian
This question already has an answer here:
remove objects from array by object property
3 answers
I have two JavaScript objects:
object_1 = [
{'value': '9:00', 'text':'9:00 am', 'eventtime':'09:00:00' },
{'value': '9:30', 'text':'9:30 am', 'eventtime':'09:30:00' },
{'value': '10:00', 'text':'10:00 am', 'eventtime':'10:00:00' },
{'value': '10:30', 'text':'10:30 am', 'eventtime':'10:30:00' },
{'value': '11:00', 'text':'11:00 am', 'eventtime':'11:00:00' },
{'value': '11:30', 'text':'11:30 am', 'eventtime':'11:30:00' },
];
object_2 = [
{'eventtime': '10:30:00'},
{'eventtime': '11:00:00'}
];
I want to remove the object in object_1 which has the same eventtime value and store it in a new array/object . Please help me do so, I cant find a solution to this.
This will be the new array/object:
object_new = [
{'value': '9:00', 'text':'9:00 am', 'eventtime':'09:00:00' },
{'value': '9:30', 'text':'9:30 am', 'eventtime':'09:30:00' },
{'value': '10:00', 'text':'10:00 am', 'eventtime':'10:00:00' },
{'value': '11:30', 'text':'11:30 am', 'eventtime':'11:30:00' },
];