Bug Tracker

Modify

Ticket #5750 (closed bug: fixed)

Opened 3 years ago

Last modified 3 years ago

$.extend copies by reference, even with deep=true (patch)

Reported by: fortes Owned by:
Priority: minor Milestone: 1.4
Component: core Version: 1.4a2
Keywords: extend Cc:
Blocking: Blocked by:

Description

a = { arr: [1, 2, 3] }

b = $.extend(true, {}, a)

b.arr.pop()

Should be false, but is true

a.arr === b.arr

Attachments

deep-extend-array.patch Download (2.4 KB) - added by fortes 3 years ago.

Change History

Changed 3 years ago by fortes

comment:1 Changed 3 years ago by fortes

With real formatting:

a = { arr: [1, 2, 3] }
b = $.extend(true, {}, a)
b.arr.pop()

// Should be false, but is true
a.arr === b.arr

comment:3 Changed 3 years ago by fortes

I shouldn't continue to code on low sleep, but here's a more compact version (ignore the attached patch):  http://github.com/fortes/jquery/commit/8c77139415ba86024b545dde326e9fee9b06fb4c

comment:4 Changed 3 years ago by john

  • Status changed from new to closed
  • Resolution set to fixed

Please follow the  bug reporting guidlines and use  jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

View

Add a comment

Modify Ticket

Action
as closed
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.