The first array is a master list of date objects containing unique javascript Date objects:
[
{'date': dateobject1, 'value': null},
{'date': dateobject2, 'value': null},
{'date': dateobject3, 'value': null},
etc...
]
The first array is a much smaller list of date objects containing a subset of the unique javascript Date objects, with the 'value' property always having a number rather than a null
:
[
{'date': dateobject3, 'value': 3117},
{'date': dateobject8, 'value': 14},
etc...
]
Keeping in mind the nuances of comparing date objects - https://stackoverflow.com/a/493018/538962 - what would be the most efficient way to merge these objects - in an environment where lodash 3.10.1 is available -
based on matching dates so that the merged array is a list of all dates: matches mean the 'value' becomes the numeric value, and otherwise the null
'value' is retained when there is no match?
[
{'date': dateobject1, 'value': null},
{'date': dateobject2, 'value': null},
{'date': dateobject3, 'value': 3117},
{'date': dateobject4, 'value': null},
{'date': dateobject5, 'value': null},
{'date': dateobject6, 'value': null},
{'date': dateobject7, 'value': null},
{'date': dateobject8, 'value': 14},
etc...
]