Using this code...
var a = ['volvo','random data'];
var b = ['random data'];
var unique = $.grep(a, function(element) {
return $.inArray(element, b) == -1;
});
var result = unique ;
alert(result);
...I am able to find which element of Array "a" is not in Array "b".
Now I need to find:
- if an element of Array "a" is in Array "b"
- what is its index in Array "b"
For example "Random data" is in both arrays, so I need to return its position in Array b which is zero index.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…