Replace elements of array

I have two arrays as follows:

array1 = [
 {
  "id":"1",
   "name":"George",
   "City":"california"
 },
 {
  "id":"2",
   "name":"James",
   "City":"Paris"
 },
  {
  "id":"3",
  "name":"Julie",
  "City":"rome"
 }
]

array2 = [
 {
  "id":"2",
   "name":"jonty",
   "City":"wales"
 },
 {
  "id":"5",
   "name":"kite",
   "City":"mumbai"
 },
  {
  "id":"3",
  "name":"neha",
  "City":"pune"
 }
]

I want to check if any element with particular id in array2 exist in array1. If element with that id exist, then replace that element in array1 else push that element in array1. Final array will look as follows:

finalArray = [
{
  "id":"1",
   "name":"George",
   "City":"california"
 },
 {
  "id":"2",
   "name":"jonty",
   "City":"wales"
 },
  {
  "id":"3",
  "name":"neha",
  "City":"pune"
 },
 {
  "id":"5",
   "name":"kite",
   "City":"mumbai"
 }
]

How can I do that?