title: How to dynamically create an expression using javascript and alpine.js
body: <p>I'm trying to create a conditional menu in a datatable. For some records the menu will appear, in other cases it will not. My backend (PHP) sends the following parameters to the frontend:</p>
  <pre><code>['field' =&gt; 'blocked_at', 'operator' =&gt; '!==', 'value' =&gt; null]
  </code></pre>
  <p>or</p>
  <pre><code>['field' =&gt; 'blocked_at', 'operator' =&gt; '===', 'value' =&gt; null]
  </code></pre>
  <p>So in HTML I call the function</p>
  <pre><code>&lt;template x-if=&quot;checkConditions(record[action.conditions.field], action.conditions.operator, action.conditions.value)&quot;&gt;
   &lt;a href=&quot;#!&quot; class=&quot;dropdown-item&quot; x-on:click=&quot;runAction(action, record[action.keyfield])&quot;&gt;
    &lt;i x-bind:class=&quot;action.icon&quot;&gt;&lt;/i&gt;&lt;span x-text=&quot;action.label&quot;&gt;&lt;/span&gt;
   &lt;/a&gt;
  &lt;/template&gt;
  </code></pre>
  <p>function in Alpine.js</p>
  <pre><code>checkConditions (field, operator, value) {
   let condition = `${field} ${operator} ${value} ? true : false`;
   return eval(condition);
  },
  </code></pre>
  <p>But it doesn't work, I'm getting the error &quot;identifier starts immediately after numeric literal&quot;. I don't know why this happens. There is an error in the checkConditions function.</p>
  <p>Could you help me solve this challenge?</p>