I will need to make a few assumptions to answer your question. First, for example, in the comments for, A2 not valid Javascript. So let go of what Louis offers, and use the format [{ 1: 'val 1' }, ...] instead. Secondly, is there only one key in A2 objects, or do we need to look for them? For simplicity, I'll take the first one.
Given these assumptions, the following will work:
_.filter(A2, function(d) { return _.contains(A1, _.parseInt(_.keys(d)[0])); });
Unlike most of the functions of Lo-dash, those used here do not perform too much abstraction from a simple Javascript dictionary. Given a browser that supports ECMAScript 5, you can replace Lodash wrappers with the following to get the same functionality:
A2.filter(function(d) { return A1.indexOf(parseInt(Object.keys(d)[0])) !== -1; });
Yony
source share