I've encountered a weird situation, I've been using the extend library and the _.extend
command from underscore, in the following way:
var extended = extend({}, objA, objB);
I get only properties from one of the objects in the result, is there anything about extend that might be preventing it from getting all the properties from both objects?
I've used this pattern everywhere and it seemed to work as expected so far. Both are plain objects, not arrays or functions.
EDIT: I tried to make a demo, but it seems to work with both jQuery and Underscore - http://jsfiddle.net/x4UHQ/2/
While making the demo (from the objects I printed in my logs), I noticed one that when printed in console.log
didn't appear as a string - it's a mongoose type of ObjectId, maybe that's somehow causing the problem? (that specific field exists in the output object, so I don't know)
UPDATE: this was the solution - UnderscoreJS wont extend object (add a lean option to the mongoose query - because that's somehow makes the object incompatible with underscore.