Reputation: 100070
I often times use _.extend or _.defaults (the Underscore library) with two objects to do JS mixins. But sometimes I fear property collision on JS objects. Is there some module I can use to check this at runtime?
Upvotes: 0
Views: 53
Reputation: 6153
I don't know about a module, but it's pretty quick to write yourself. Since you mentioned underscore:
function objectsCollide(objA, objB) {
var keysA = _.allKeys(objA);
var keysB = _.allKeys(objB);
return _.intersection(keysA, keysB).length ? true : false;
}
Upvotes: 1