title: JavaScript: Is Prototype Synonymous with Static?
body: <p>I am teaching myself JavaScript coming from a OOP background. The book in which I am studying has made me think, "Wow, properties are almost the same as static methods or variables!" If this is the case I would love to implement them more to save some memory, but before I fall in love with them I want to make sure I'm using them correctly. </p>
  
  <p><p> Is this the case? Is my logic wrong? I am adding some sample code below to use as context for my question. Hopefully it's not oversimplified:</p>
  
  <pre><code>function person(first, age){
      this.firstName = first;
      this.age = age;
  }
  
  person.prototype.sayHello = function(){
      return "hi my name is " + this.firstName + " and I am " + age + ".";
  };
  </code></pre>
  
  <p>and thus the constructor function could be called the following way</p>
  
  <pre><code>var me = new person("Dan", 22);
  </code></pre>
  
  <p>Also, does this break encapsulation? The example above does not declare the variables in the class so they will be globally scoped. I understand the prototype would not be able to see <code>firstName</code> or <code>age</code> if they were declared <code>var firstName</code> and <code>var age</code>.</p>
  
  <p>Do I have to pick one or the other? Can I not use my added prototypes and encapsulation? </p>
  
  <p>Thanks ahead of time! </p>