Is there a way to choose dynamicaly an operator
do something like this:
var val1="1",
val2="1",
oper="===";
if(val1 oper val2){
console.log("im in");
}else{
console.log("im out");
}
You can not do a dynamic operator, but you can achieve the same thing using functions instead.
var val1 = "1",
val2 = "1",
oper = function(a, b) { return a === b; };
if(oper(val1, val2)) {
console.log("im in");
} else {
console.log("im out");
}
evalis an option if you have control over the input.