0

I got an assignment where a DB has operator conditions (===, <, >, * etc) to use with some accompanying data.

I need to run those conditions in my JavaScript code. What I found around here is usage of eval or the Function constructor, but both have crucial security and performance issues and are not an option for production code in any sense.

Example:

const operatorFromDB = '>'

const param1FromDB = '10'

const param2FromDB = '5'

But running eval('${param1FromDB}${operatorFromDB}${param2FromDB}') is problematic.

So, how do I actually solve this?

flow24
  • 793
  • 2
  • 5
  • 17

0 Answers0