3 ways to merge 2 JSON objects with the same key in JavaScript

All About Code
2 min readSep 21, 2022

The 3 ways to merge 2 JSON objects are

  1. Nested for loop
  2. Map and Object.assign
  3. concat()

1. Nested for loop

<!DOCTYPE html><html><body><script type="text/javascript">var g = [{ id: 36, name: 'AAA', goal: 'yes' },{ id: 40, name: 'BBB', goal: 'yes' },

--

--