I have some variables
var a = true;
var b = false;
var c = true;
and an array
var array = ['a', 'b', 'c'];
How is it possible to evaluate the elements to their corresponding truth value?
I know I can use eval(), but since it is considered harmful, are there any other options?
In some cases I will rather have the 'truth' assignment as
var truth = {'a': true, 'b': false, 'c': true};
and it seems, eval() doesn't take another option (e.g. eval('a+b', {a: 1, b: 3}) = 4)
window['a'] == trueifais a global variable?add(({a, b}) => a+b)({a: 1, b: 3}).evalis a tool, just one generally used for evil. It can be used fine and properly if used carefully and sparingly. I'd never ship any library code with it, but I'd also probably never run into whatever craziness you appear to try to be doing. : ) Really, your problem most likely lies in how you're trying to attack it in the first place, not in some magical need for an eval-like construct.