Skip to content

Instantly share code, notes, and snippets.

@geomago
Last active June 19, 2020 14:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save geomago/6b7ed81c0b618773c947f0ec73a5e2b2 to your computer and use it in GitHub Desktop.
Save geomago/6b7ed81c0b618773c947f0ec73a5e2b2 to your computer and use it in GitHub Desktop.
merge_arrays_2
let allCars = cars2.reduce(
(result,item) => {
if ( cars.findIndex( car => car.id == item.id ) < 0) {
result.push(item);
}
return result;
},
cars.slice(0)
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment