KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I have code similar to this filtering entries in an Array of Objects: var filterRegex = new RegExp(".*blah.*","ig"); if (filterRegex.test(events[i].thing) && events[i].show) { console.log("SUCCESS: filtering thing " + i + " " + events[i].thing); events[i].show = false; numevents--; } I get inconsistent results with this if condition (checking with Firebug, both conditions are true individually, but sometimes the whole expression evaluates to false). HOWEVER, if I actually put an alert() called inside this if statement (like line 4), it becomes consistent and I get the result I want. Can you see anything wrong with this logic and tell me why it's not always producing what is expected?
Tags (comma-separated)
Save Edits
Cancel