Skip to main content

Bug Tracker

Side navigation

#14722 closed bug (notabug)

Opened January 23, 2014 06:26PM UTC

Closed January 23, 2014 07:31PM UTC

Last modified January 23, 2014 07:44PM UTC

Recursively extending as object with another object with an empty array parameter

Reported by: jasonlfunk@gmail.com Owned by:
Priority: undecided Milestone: None
Component: unfiled Version: 2.0.3
Keywords: Cc:
Blocked by: Blocking:
Description
#!js

var obj1 = {'key': {'subkey': 1} }
>> Object {key: Object}

var obj2 = {'key': [] }
>> Object {key: Array[0]}

$.extend(true, obj1, obj2)
>> Object {key: Array[0]}

I would expect the result to still contain the 'subkey' object; instead it is replaced by an empty array.

Attachments (0)
Change History (4)

Changed January 23, 2014 07:31PM UTC by rwaldron comment:1

resolution: → notabug
status: newclosed

This is the correct behaviour, jQuery.extend will not attempt to "merge" an Array and an Object.

Changed January 23, 2014 07:35PM UTC by dmethvin comment:2

This wouldn't be a problem if you'd define an Arrobject in ES7.

Changed January 23, 2014 07:42PM UTC by dmethvin comment:3

On second thought there should also be an Objectray for symmetry.

Changed January 23, 2014 07:44PM UTC by rwaldron comment:4

Replying to [comment:2 dmethvin]:

This wouldn't be a problem if you'd define an Arrobject in ES7.

Replying to [comment:3 dmethvin]:

On second thought there should also be an Objectray for symmetry.

*starting writing proposal*