There has been a lot of talk about the dangers of using the eval()
function in HTML/JavaScript programming. While I want to pass in a string to have it read as a variable name, I am aware of the risks associated with using eval()
. It seems like the function I need, but I am hesitant to use a potentially harmful function.
My understanding is that eval()
can execute third-party input as code, leaving room for security vulnerabilities. I have a map element that uses strings to represent location names, and I store large text blocks in variables for easy access to location descriptions. This seems like a scenario where eval()
could be used safely, as the input strings are generated within the code. Am I making a sound judgement, or is there a better alternative function to consider?