Intersect, Subtract and Add functions for objects in JavaScript