2

Here is my following code,

points1 = [{x:'10'},{x:'20',fill:'red'}]
points2 = [{x:'30'},{x:'30'}]

   $.extend(true, points1, {}, points2);

it will be returned points1 as [{x:'30'},{x:'30',fill:'red'}] but what i need is ,if the fill is not available in points2 there should reflect..

my expected o/p is points1 = [{x:'30'},{x:'30'}]

how to achieve?

2
  • 3
    Your points variables are Arrays. $.extend() needs Objects Commented Mar 25, 2016 at 9:15
  • it's not clear enough what is you desired result. looks like you want to merge 2 arrays using some condition, but that condition is unclear Commented Mar 25, 2016 at 9:28

1 Answer 1

2

You were so close. Just replace :

$.extend(true, points1, {}, points2);

with :

$.extend(false, points1, {}, points2);
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.