Bug Tracker

Opened 6 years ago

Closed 6 years ago

Last modified 6 years ago

#14722 closed bug (notabug)

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

Reported by: jasonlfunk@… Owned by:
Priority: undecided Milestone: None
Component: unfiled Version: 2.0.3
Keywords: Cc:
Blocked by: Blocking:

Description

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.

Change History (4)

comment:1 Changed 6 years ago by Rick Waldron

Resolution: notabug
Status: newclosed

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

comment:2 Changed 6 years ago by dmethvin

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

comment:3 Changed 6 years ago by dmethvin

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

comment:4 in reply to:  2 Changed 6 years ago by Rick Waldron

Replying to dmethvin:

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

Replying to dmethvin:

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

*starting writing proposal*

Note: See TracTickets for help on using tickets.