Using JSlint to test my javascript.
I get an error is eval is evil! Why is this an alternative that I can use?
Here is an example of where I am using eval and would like a workaround for it.
I have an array like this:
var Resources = { message_1: 'Message 1', message_2: 'Message 2', message_3: 'Message 3', message_4: 'Message 4' };
I have a function (functionResult) that returns a number, either 1, 2, 3, or 4. So, what I want to do in the next line of code is to get a resource in an array that ends there as a result of my function.
$('#divPresenter').html(eval($.validator.format('Resources.message_{0}', functionResult)));
Any ideas on how I can remove eval and replace with something else?
source share