title: Angular.js: How does $eval work and why is it different from vanilla eval?
body: <p>I was curious about the <code>$scope.$eval</code> you so often see in directives, so I checked out the source and found the following in <code>rootScope.js</code>:</p>
  
  <pre><code>  $eval: function(expr, locals) {
      return $parse(expr)(this, locals);
    },
  </code></pre>
  
  <p><code>$parse</code> appears to be defined by <code>ParseProvider</code> in <code>parse.js</code>, which appears to define some kind of mini-syntax of its own (the file is 900 lines long).</p>
  
  <p>My questions are:</p>
  
  <ol>
  <li><p>What exactly is <code>$eval</code> doing?  Why does it need its own mini parsing language?</p></li>
  <li><p>Why isn't plain old JavaScript <code>eval</code> being used?</p></li>
  </ol>