You could, although it's evil, use an eval after joining all the array elements.
i.e.
var arr = [true, '&&', false];
if(eval(arr.join(''))){
// your code
}
Update:
I just recently thought of a much simple (not simpler than eval) but safe answer. If the only boolean operations you're using are && and || and the parentheses are properly formatted, then you could do a bunch of regex replaces until there is only one value left, either "true" or "false".
The boolean values for AND operations can only be as follows and they simplify to either true or false
true && true == true
true && false == false
false && true == false
false && false == false
the same goes for OR operations
true || true == true
true || false == true
false || true == true
false || false == false
As a result, we can replace the expression with their simplified values - true or false. Then, if there are parentheses around the expression it'll end up as either '(true)' or '(false)' and we can easily regex replace that as well.
We can then loop this routine until we're finally left with one value, either 'true' or 'false'.
i.e. in code
var boolArr = ["(", true, "&&", "(", false, "||", true, ")", ")", "||", true];
//Convert the array to a string "(true&&(false||true))||true"
var boolString = boolArr.join('');
//Loop while the boolean string isn't either "true" or "false"
while(!(boolString == "true" || boolString == "false")){
//Replace all AND operations with their simpler versions
boolString = boolString.replace(/true&&true/g,'true').replace(/true&&false/g,'false');
boolString = boolString.replace(/false&&true/g,'false').replace(/false&&false/g,'false');
//Replace all OR operations with their simpler versions
boolString = boolString.replace(/true\|\|true/g,'true').replace(/true\|\|false/g,'true');
boolString = boolString.replace(/false\|\|true/g,'true').replace(/false\|\|false/g,'false');
//Replace '(true)' and '(false)' with 'true' and 'false' respectively
boolString = boolString.replace(/\(true\)/g,'true').replace(/\(false\)/g,'false');
}
//Since the final value is a string of "true" or "false", we must convert it to a boolean
value = (boolString == "true"?true:false);
Annd, if you're really dangerous, you can chain all those replaces together
Also, please notice the lovely lack of recursion and use of only one loop
['(', ';', true', ')']?May 12, this year notMay '12, no? Am I missing something?