I have two arrays:
var array_old = [{id:\"5436\", title:\"I Like you boy\"}, {id:\"5437\", title:\"Hello how are you\"}];
var array_new = [{id:\"5436\", title:\"
Depends on how big your arrays are - you might want to use a more performant solution.
Θ(n*m)
O(n*m)
O(min(n,m))
. If you'd need to sort them before that, you'd get O(n*log n+m*log m)
.O(1)
lookup, resulting in O(n+m)
. You can easily use a JS object for that:var counts = {};
for (var i=0; i
(Demo)