I'm trying to write a condition that accumulates filters at run-time and builds a conditional statement that looks something like:
location == "mumbai" || location == "tokyo" && type == "car" || ....
which can then be inserted into an if statement.
There are plenty of questions for similar or identical requests on StackOverflow and other forums, but best I can tell they all seem to use JavaScript's eval() method which is A: Not considered safe, and B: the code you have to write to facilitate eval() is messy and undesirable. Is there a way to do this without eval()?
Aucun commentaire:
Enregistrer un commentaire