title: Evaluate string in javascript without eval
body: <p>I have some variables</p>
  
  <pre><code>var a = true;
  var b = false;
  var c = true;
  </code></pre>
  
  <p>and an array</p>
  
  <pre><code>var array = ['a', 'b', 'c'];
  </code></pre>
  
  <p>How is it possible to evaluate the elements to their corresponding truth value?</p>
  
  <p>I know I can use <code>eval()</code>, but since it is considered harmful, are there any other options?</p>
  
  <p>In some cases I will rather have the 'truth' assignment as</p>
  
  <pre><code>var truth = {'a': true, 'b': false, 'c': true};
  </code></pre>
  
  <p>and it seems, <code>eval()</code> doesn't take another option (e.g. <code>eval('a+b', {a: 1, b: 3}) = 4</code>)</p>