title: How do I 'hide' variables in Javascript whilst exposing public static methods?
body: <p>I am currently rewriting some scientific C++ code using Javascript and I would like to keep the same basic organisation if at all possible. In the C++ code, there are a number of classes that contain a bunch of <code>const</code> data in the from of many different arrays and a series of <code>public static</code> methods that work on that data. I'm struggling with how to replicate something like this in Javascript.</p>
  
  <p>At the moment I'm using something like the following:</p>
  
  <pre><code>function mars(){}
  
  mars.x = [{A:1, B:2, C:3},{A:1, B:2, C:3}]; //...
  mars.y = [{A:1, B:4, C:2},{A:1, B:2, C:3}]; //...
  // ...about 600 lines in total
  
  mars.doSomething = function(foo){
      var result = 0;
      // Do lots of processing of above arrays
      return result;
  }
  
  mars.doSomethingElse = function(bar){
      var result = 0;
      // Do lots of processing of above arrays
      return result;
  }
  
  console.log(mars.doSomething(3))
  </code></pre>
  
  <p>This works, but it exposes <code>mars.x</code> etc. to the rest of the code which really doesn't need to know about it. If I use <code>prototype</code> the methods will no longer be static and the code will be littered with <code>new</code> calls, something I don't really want.</p>
  
  <p>What I'm asking then, is: How do I hide variables in JavaScript whilst exposing static methods to the rest of the code? Or am I worrying about something I shouldn't be?</p>