I have the following situation:
var newObject = {user: object, user1: object1}
var user = "something";
var object = {key: [obj, obj], key1: [obj, obj]}
I'd want to add the following to the array of objects in var object:
var addToIt = [objA, objB];
In the end var object should look like:
var object = {key: [obj, obj, objA, objB], key1: [obj, obj]}
I believe there is a way to do it with underscore but until now I've not been able to figure it out. A solution or suggestion would be much appreciated!
In an effort to share my approach, here is something I thought would work but I'm getting an error when I try to push and undefined values for key and key1:
var newHistory = _.mapObject(newObject, function(valN, keyN){
_.mapObject(valN, function(vs, ks){
if(ks = key){
return vs.push(addToIt);
}
})
})
object.key=object.key.concat(addToIt);(concat) which makes it a near duplicate of stackoverflow.com/questions/21811184. I’m sure theconcatfunctionality has been covered on StackOverflow before, multiple times.