I have an array of javascript objects,
let headers = [
{
text: 'something',
value: 'something else'
},
{
text: 'something1',
value: 'something else1'
},
// etc..
]
I want to loop through the array and add a method to each object in the array like so (ignore "this", I'm using vue):
this.headers.map(h => {
h['filter'] = function (value) {
if (!this.filterValue) {
return true;
}
return value.toLowerCase().includes(this.filterValue.toLowerCase());
}
});
It looks fine to me, but when my loop completes, the function does not work, and I think it has something to do with this error in "arguments" and "caller":
Any ideas on how to resolve this error?