I have 2 objects, and combine them by using jQuery.extend function.
john_5_years_ago = {
name: "john",
company: "google",
languages: ["c++", "java"]
}
john_now = {
name: "john",
company: "facebook",
nation: "US",
languages: ["python", "java", "javascript"]
}
$.extend(true, {}, john_5_years_ago, john_now)
It returns result like this:
{
name: "john",
company: "facebook",
nation: "US",
languages: ["python", "java", "javascript"]
}
But I expected the value of languages array should be merged, not be overwritten. And the expected result should be like this:
{
name: "john",
company: "facebook",
nation: "US",
languages: ["python", "java", "javascript", "c++"]
}
I'll appreciate any ideas.