I hava a variable this.myvar
which is a array. I would like to make a _.filter()
with this variable, but within the _.filter()
-function my this.myvar
is not known.
is there a way to solve this, or did I comepletely misunderstood something?
this.my_array = ['aaa', 'bbb', 'ccc', 'ddd'];
this.my_filter = ['aaa', 'ccc'];
my_filtered_object = _.filter(this.my_array, function(item) {
alert(this.my_filter.toSource());
/*
if(this.my_filter.indexOf(item) != -1) {
return item;
}
*/
});
the alert should show the values of this.my_filter
but it seems that there is no access within _.filter()
to that variable