var allOptions = [
{value: 'AA', key: 'a'},
{value: 'BB', key: 'b'},
{value: 'CC', key: 'c'},
{value: 'DD', key: 'd'},
{value: 'EE', key: 'e'}
];
var selected = ['a', 'c'];
I want to get objects from allOptions
which have keys in variable array selected
i.e I want result as
[
{value: 'AA', key: 'a'},
{value: 'CC', key: 'c'},
];
Any suggestions appreciated if not involving jquery.