title: Escape \u200b (Zero width space) and other illegal JavaScript characters
body: <p>I have a set of JavaScript objects I bootstrap to a backend template to initialise my Backbone.js collections on page load. It looks something like this (as Twig template): </p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
  (function() {
      var jobCollection = new App.Collections.Item(
          {% for item in items %}
          {
              name: '{{ item.name }}',
              ...
          },
          {% endfor %}
      );
  })();
  &lt;/script&gt;
  </code></pre>
  
  <p>The problem I'm having is that some text fields contain \u200b (Zero width space) that break the JavaScript.</p>
  
  <p>What is the best way to escape these characters? Should I escape them in the backend (I'm using Symfony 2 with Twig to render the initial template) or should I escape them on the client with JavaScript? How can I escape the zero width space character and others in JavaScript or PHP?</p>