Oh sorry I missed the prop. In that case, a computed property would be better.
Also, you should rename your prop to hashtags since it's an array that can contain multiple hashtags. I will use hashtags in my examples. The following examples also assume that it is an array of strings.
There are two main options :
1. Partial match
Example: if your prop contains the #he hashtag, it would match notifications with the #he hashtag, but also with the #hello hashtag
computed: {
hashtagsFilteredNotifications() {
return this.notifications.filter(notification => {
return this.hashtags.some(hashtag => notification.hashtags.includes(hashtag));
});
}
}
2. Exact match
Example: if your prop contains the #he hashtag, it would match notifications with the #he hashtag, but will NOT match notifications with the #hello hashtag
// The lodash library is installed by default in Laravel apps
import escapeRegExp from 'lodash/escapeRegExp';
computed: {
hashtagsRegExp() {
let regExpFormattedHashtags = this.hashtags.map(hashtag => escapeRegExp(hashtag.replace('#', ''))).join('|');
return new RegExp(`\\B#(${regExpFormattedHashtags})\\b`);
},
hashtagsFilteredNotifications() {
return this.notifications.filter(notification => {
return notification.hashtags.some(hashtag => this.hashtagsRegExp.test(hashtag));
});
}
}