I'm trying to merge all objects together using lodash and I tried _.assign and _.merge still it shows the objects separately.
var arr = [
{"asf" : 33, "ff1" : 12},{"xx" : 90, "ff2" : 13},{"xw" : 66, "ff3" : 176}
]
console.log( _.assign({}, arr)); //should show {"asf" : 33, "ff1" : 12,"xx" : 90, "ff2" : 13, "xw" : 66, "ff3" : 176}
http://jsfiddle.net/ymppagdq/
This is how you can do it:
_.assign.apply(_, arr);
or _.reduce(arr, _.extend)
would also work.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With