title: Find details of SyntaxError thrown by javascript new Function() constructor
body: <p>When creating new function from JavaScript code using new Function(params,body) constructor, passing invalid string in body yelds SyntaxError. While this exception contains error message (ie: <code>Unexpected token =</code>), but does not seem to contain context (ie. line/column or character where error was found). </p>
  
  <p>Example fiddle: <a href="https://jsfiddle.net/gheh1m8p/" rel="noreferrer">https://jsfiddle.net/gheh1m8p/</a></p>
  
  <pre><code>var testWithSyntaxError = "{\n\n\n=2;}";
  
  try {
      var f=new Function('',testWithSyntaxError);
  } catch(e) {
    console.log(e instanceof SyntaxError); 
    console.log(e.message);               
    console.log(e.name);                
    console.log(e.fileName);            
    console.log(e.lineNumber);           
    console.log(e.columnNumber);         
    console.log(e.stack);               
  }
  </code></pre>
  
  <p>Output:</p>
  
  <pre><code>true
  (index):54 Unexpected token =
  (index):55 SyntaxError
  (index):56 undefined
  (index):57 undefined
  (index):58 undefined
  (index):59 SyntaxError: Unexpected token =
      at Function (native)
      at window.onload (https://fiddle.jshell.net/_display/:51:8)
  </code></pre>
  
  <p><strong>How can I, without using external dependencies, pinpoint SyntaxError location withinn passed string?</strong> I require solution both for browser and nodejs.</p>
  
  <p>Please note: I do have a valid reason to use eval-equivalent code.</p>