elad.chen
elad.chen

Reputation: 2425

deep copy object array properties value with jQuery

Take a look at this snippet:

$.extend( true, {}, { key: ["somevalue"] }, { key: ["anothervalue"] })

doing this I expect the produced object will contain a property called "key" which is an array and has 2 elements, e.g

{ key: ["somevalue", "anothervalue"] }

Am I just giving the deep copy more than it can handle?

Upvotes: 0

Views: 61

Answers (1)

Kiba
Kiba

Reputation: 10827

Nop !! The result will be a object containing key having value ["anothervalue"], you are basically overriding the "key" as you pass more objects in the arguments with key as "key"

Thanks

Upvotes: 1

Related Questions