Using this code...
var a = [\'volvo\',\'random data\']; var b = [\'random data\']; var unique = $.grep(a, function(element) { return $.inArray(element, b
Regarding your comment, here is a solution:
with jQuery:
$.each( a, function( key, value ) { var index = $.inArray( value, b ); if( index != -1 ) { console.log( index ); } });
without jQuery:
a.forEach( function( value ) { if( b.indexOf( value ) != -1 ) { console.log( b.indexOf( value ) ); } });