Skip to main content

Bug Tracker

Side navigation

#14614 closed bug (duplicate)

Opened December 06, 2013 06:56PM UTC

Closed December 06, 2013 07:46PM UTC

Extended objects share single array

Reported by: Owned by:
Priority: undecided Milestone: None
Component: unfiled Version: 1.10.2
Keywords: Cc:
Blocked by: Blocking:

I am not sure if this is a bug, a lack of documentation, or a misunderstanding on my part so I apologize in advance.

When using jQuery.extend() to merge 2 objects (obj1, and obj2) into a new empty object (target), any arrays from obj2 are actually shared between instances of target. So if any instance of target modifies the array, all instances see the change.

A code example is worth a thousand words so please check the following jsfiddle:

I would expect the console output for the array to say just ["cat"] but instead it says ["chicken", "bird", "cat"].

Attachments (0)
Change History (2)

Changed December 06, 2013 07:01PM UTC by comment:1

It appears there was an issue during my submit and it double posted. Please close this issue as a duplicate of

Changed December 06, 2013 07:46PM UTC by gibson042 comment:2

resolution: → duplicate
status: newclosed

Duplicate of #14613.