Hacker News new | ask | show | jobs
by ralston 2925 days ago
Python 3.5+

  >>> first = {"a": 1}
  >>> second = {"b": 2}
  >>> merged = {**x, **y}
  >>> print(merged)
  {"a": 1, "b": 2}
2 comments

  merged = {**first, **second}
Same exists in ES6:

    const first = { a: 1 };
    const second = { b: 2 };
    const merged = { ...first, ...second };
    console.log(merged) // { a: 1, b: 2 }
Python had it first ;)