I am dealing with an array of JavaScript objects that I need to modify. Here is an example of the initial setup:
let headers = [
{
text: 'something',
value: 'something else'
},
{
text: 'something1',
value: 'something else1'
},
// etc..
]
My goal is to loop through this array and add a custom method to each object, as shown below (please note that "this" refers to Vue in this context):
this.headers.map(h => {
h['filter'] = function (value) {
if (!this.filterValue) {
return true;
}
return value.toLowerCase().includes(this.filterValue.toLowerCase());
}
});
Despite my efforts, the added function does not work after the loop completes. Upon further investigation, I noticed an error related to "arguments" and "caller". Here's a link to the detailed error message: https://i.sstatic.net/tbm0p.png
Can anyone provide insights on how to troubleshoot and fix this issue?