Q:

Converting string to expression

Is there any way to convert a string to an expression? 
my string: var1 == null && var2 ! = 5
I want to use this string as a condition of the if(), Like if(var1 == null && var2 ! = 5)

A:

Use eval.  This will do
if (eval(" var1 == null && var2 ! = 5"))
{
}

A:

One option is to create and call new Function:
var strExpr = "var1 == null && var2 ! = 5";
if (new Function("return " + strExpr)()) {
    // ...
}

