title: JS Get File Contents?
body: <p>I'm creating a new language, with a JavaScript parser, and I'm currently trying to figure out how to get a local file's contents. I tried using a <code>XMLHttp</code>request which looked like this:  </p>
  
  <pre><code>var rawFile = new XMLHttpRequest();
  rawFile.open("GET", "testing.txt", true);
  </code></pre>
  
  <p>But that didn't work. I got this error in my terminal:  </p>
  
  <pre><code>`(function (exports, require, module, __filename, __dirname) { var rawFile = new XMLHttpRequest();
      ^`
  
  ReferenceError: XMLHttpRequest is not defined
      at Object.&lt;anonymous&gt; (/home/ubuntu/workspace/source.js:1:81)
      at Module._compile (module.js:409:26)
      at Object.Module._extensions..js (module.js:416:10)
      at Module.load (module.js:343:32)
      at Function.Module._load (module.js:300:12)
      at Module.runMain [as _onTimeout] (module.js:441:10)
  
  `Process exited with code: 1`  
  </code></pre>
  
  <p>I know Python can get a file's contents using the <code>subprocess</code> module:  </p>
  
  <pre><code>import subprocess
  with open(file, 'r') as myfile:
  data=myfile.read().replace('\n', '')`  
  </code></pre>
  
  <p>So should I just switch over to Python instead? Or is there a way to use JavaScript?</p>