<p>I have code similar to this filtering entries in an Array of Objects:</p>

<pre><code>var filterRegex = new RegExp(".*blah.*","ig");
if (filterRegex.test(events[i].thing) &amp;&amp; events[i].show) {
    console.log("SUCCESS: filtering thing " + i + " " + events[i].thing);
    events[i].show = false;
    numevents--;
}
</code></pre>

<p>I get inconsistent results with this if condition (checking with Firebug, both conditions are true individually, but <em>sometimes</em> the whole expression evaluates to false). HOWEVER, if I actually put an <code>alert()</code> called inside this if statement (like line 4), it becomes consistent and I get the result I want.</p>

<p>Can you see anything wrong with this logic and tell me why it's not always producing what is expected?</p>

I just can't imagine there is any situation where two JavaScript expressions evaluate to true individually, but not when combined.
Are you sure both expressions actually produce a boolean value every time? (Okay, to make
```
regex.test()
```
not produce a boolean value is difficult, but how about
```
event.show
```
. Might that be undefined at times?
Do you refer to the correct index when saying
```
event[0].show
```
, wouldn't you mean
```
event[i].show
```
?