I have this bit of code inside a function. It is supposed to filter a global variable RESTRICTIONS
to any keys that start with this.label
. In this example RESTRICTIONS=={"lm.tags": "something"}
and this.label=="lm"
. It has the opposite result from what is expected! I actually want it to match, which it does. But I would expect to use >
and not ==
inside the filter function. Even if pause the code on this line and run other tests using literal strings or any variable set to "lm" it works the way you would expect, but when I set search lm.label
it starts working backwards! It makes no sense!!! Is it some kind of bug? I am using Chrome 80 on Windows.
var matchingKeys = Object.keys(RESTRICTIONS)
.filter(function(x){
return x.indexOf(this.label)==-1
})
//result: ["lm.tags"]
//expected: []