JSFiddle - React, Tailwind, and code Playground

JavaScript

var array1 = ["a", "b", "c", "d", "e", "f"];
var array2 = ["a", "b", "c", "d", "e", "f", "g", "h", "i"];
var foo = [];

$.grep(array2, function (el) {

    if ($.inArray(el, array1) != -1) {
        foo.push(el);
    }

});


alert(" they have the same " + foo);