title: How to compare twig value with JS value?
body: <p><strong>Situation</strong> : I need to compare JS variable value to a Twig variable value, inside jQuery function OR somehow access specific object from Twig array based on given ID number.</p>
  
  <p>The code that describes situation :</p>
  
  <pre><code>            var id = ...;
              {% for user in userlist %}
               {% if user.id == id %}
                   var userInfo = $.parseJSON({{ user }};
               {% endif %}
              {% endfor %}
  
              $('#username-field').html(userInfo['username']);
              ...
  </code></pre>
  
  <p>OR something similar to this (if its even possible) :</p>
  
  <pre><code>            var id = ...;
              var userInfo = $.parseJSON({{ userlist|findByField('id', id }};
  
              $('#username-field').html(userInfo['username']);
              $('#title-field').html(userInfo['title']);
  </code></pre>
  
  <p><strong>Problem</strong> : Since Twig is not able to access JS value, <em>I have no idea, how to place some kind of placeholder inside twig {% ... %} brackets.</em> </p>
  
  <p>It would be nice to access selected object from collection that is already send by request to Twig template, instead of creating new Ajax request, to get particular object once again from controller.</p>