title: How to evaluate set inclusion tests using JavaScript?
body: <p>I want to eval expressions to check for truthiness.</p>
  
  <p>The user is giving me expressions in the form of </p>
  
  <pre><code>x == y || a == (c + 3)
  </code></pre>
  
  <p>or </p>
  
  <pre><code>y &gt;= 4
  </code></pre>
  
  <p>I would just use eval with:</p>
  
  <pre><code>expression.replace(/[^|()\d\+-&gt;&lt;=!&amp;]/g, '');
  eval(expression);
  </code></pre>
  
  <p>Now the user wants to give me set inclusion expressions like:</p>
  
  <pre><code>5 ∈ y || 3 ∉ y
  </code></pre>
  
  <p>Where <code>y</code> is an array. What's the best safe way to handle that?</p>
  
  <p>Edit: Thanks for your help, reading over the answers it's hard to decide which one to pick / which one is better.</p>