I have two arrays that I need to merge together, they look like so:
var array1 =
[
{x: "1/12/2011", y: 4149.9}
{x: "2/12/2011", y: 4094.5}
{x: "3/12/2011", y: 3606.8}
]
and
var array2 =
[
{x: "1/12/2011", z: 3500}
{x: "2/12/2011", z: 3600}
{x: "3/12/2011", z: 3700}
]
I would like to merge them based on x where all properties are kept in the final object.
Expected output:
var excpected =
[
{x: "1/12/2011", y: 4149.9, z: 3500}
{x: "2/12/2011", y: 4094.5, z: 3600}
{x: "3/12/2011", y: 3606.8, z: 3700}
]
I've found $.extend and $.merge but haven't managed to successfully achieve what I need. Any pointers?