You wrote your allEmojis
without quotes
var allEmojis = [dog, toucan, flamingo, lion, tiger, duck, elephant, zebra]
Array of strings would be
var allEmojis = ["dog", "toucan", "flamingo", "lion", "tiger", "duck", "elephant", "zebra"]
If this is not a problem and allEmojis
really contains a strings, which are in arrayOfObjects
in every object under key object.emoji
, then you can filter intersection of allEmojis
with arrayOfObjects
like so
var filtered = allEmojis.filter(function(e) {
return !!arrayOfObjects.find(function(o) {
return o.emoji === e;
});
};
You can also write it as
var filtered = arrayOfObjects
.filter(function(o) { return allEmojis.includes(o.emoji) })
.map(function(o) { return o.emoji }); // convert objects to strings
which probably has better performance.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…