array_diff js code example
Example 1: array differenc javascript
let difference = arr1.filter(x => !arr2.includes(x));
Example 2: diff two arrays javascript
function diffArray(arr1, arr2) {
return arr1
.concat(arr2)
.filter(item => !arr1.includes(item) || !arr2.includes(item));
}
Example 3: array_diff
<?php
$array1 = array("a" => "green", "red", "blue", "red");
$array2 = array("b" => "green", "yellow", "red");
$result = array_diff($array1, $array2);
?>
Array
(
[1] => blue
)