handling of duplicate keys in Object$prototype$concat
See original GitHub issueSanctuary:
> Z.concat({x: 1, y: 1}, {y: 2, z: 2})
{x: 1, y: 2, z: 2}
Haskell:
> M.fromList [('x', 1), ('y', 1)] <> M.fromList [('y', 2), ('z', 2)]
fromList [('x', 1), ('y', 1), ('z', 2)]
We didn’t discuss this behaviour in #2 as far as I can see; I think we diverged from Haskell’s behaviour unintentionally.
/cc @puffnfresh
Issue Analytics
- State:
- Created 6 years ago
- Comments:9 (9 by maintainers)
Top Results From Across the Web
Merge duplicate keys in simple object [closed] - Stack Overflow
A javascript object cannot have duplicated keys, so this will not work. If instead you had an array of objects containing one or...
Read more >Removing duplicates in an Array of Objects in JS with Sets
My first instinct was to make a new array, and loop through the addresses' array and do a . findIndex on each for...
Read more >Object.assign() - JavaScript - MDN Web Docs
The Object.assign() static method copies all enumerable own properties from one or more source objects to a target object.
Read more >How to copy objects in JavaScript: A complete guide
A complete guide to copying objects in JavaScript: shallow copy, deep copy, assigning, merging, and structured cloning.
Read more >javascript find duplicate values in object - You.com
In JavaScript, an object consists of key-value pairs where keys are similar to indexes in an array and are unique. If one tries...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Let’s stick with the current behaviour for the time being. As it’s not clear that one approach is better than the other it’s best to leave things as they are. We can revisit this issue if new information comes to light.
In haskell
mappend
ofMap
is “left-biased” in JS we have similar functionObject.assign
(R.merge
has similar semantics) which areright biased
, so I think is better to stick with what we have as it’s more intuitive to JS developer.