Is it possible to pass a string into an if statement as a means to create dynamic if statements? A simplified example would be:
var condition = "bool == true";
if(condition) console.log('It is true!);
Of course the example above does not work, because it always returns true, because the string has content. Is there some way to inject to contents of condition into the if statement as actual parameters though? The condition needs to be in string format because in a real world application, the condition will be pulled out of an existing HTML block using a regular expression and is therefore returned in string format.
Vanilla javascript only please.