title: JavaScript Keep Console Window Open in Visual Studio
body: <p>I'm working through Basarat Ali Syed's book "Beginning Node.js", and I'm using Visual Studio 2017 (not to be confused with Visual Studio Code). I like the fact that I can view output in a console window that pops up, rather than having to go through the browser.</p>
  
  <p>However, when I run through code like the following, the console window pops up and closes before I have a chance to see the result. I know how to keep the console window open in C# (Console.Read()), but this is JavaScript. </p>
  
  <p>How do I keep the console window open with the following code?</p>
  
  <p>```</p>
  
  <pre><code>function getConnection(callback) {
      var connection;
      try {
          throw new Error('connection failed');
  
          callback(null, connection);
      }
      catch (error) {
  
          callback(error, null);
      }
  }
  
  getConnection(function (error, connection) {
      if (error) {
          console.log('Error:', error.message);
      }
      else {
          console.log('Connection succeeded:', connection);
      }
  });
  </code></pre>
  
  <p>```</p>