Q:

How to check the word in an array

I have a default array for example
a=["and","a","in","&"] etc...

Iam getting a dynamic text, which iam converting it into an array. for example.
b=["harry","in","connect"]

I need to highlight by avoiding "in" the array.
So harry and connect will be highlight but not the in?
How to compare or check the array in jquery?

A:

you can use $.inArray or $.grep, i.e.
var a=["and","a","in","&"];
var b=["harry","in","connect"];

var c = $.grep(b, function(n){
    return $.inArray(n,a) == -1;
});

This will return a new array, containing only the words NOT present in array a
Here's a fiddle: http://jsfiddle.net/kaFvw/
If you need it to return an array with all the words PRESENT in array a, just change the == operator to !=

