JavaScript use constructor parameters in methods, which way is valid?
<p>I have js object like this:</p>

<pre><code>var Dog = function(dogName) {
  this.bark = function() {
    console.log(dogName + " is barking");
  }
}
</code></pre>

<p>and </p>

<pre><code>var Dog = function(dogName) {
  this.dogName = dogName;
  this.bark = function() {
    console.log(this.dogName + " is barking");
  }
}
</code></pre>

<p>I can use both the same way:</p>

<pre><code>var puppy = new Dog("Ringo");
puppy.bark();
</code></pre>

<p>My question is is there any practical difference between those two approaches? Is it better to assign constructor parameters to <code>this.&lt;field&gt;</code>, or I can just utilize those parameters straight away as they are accessible to inner functions? Are there any special cases for both?</p>
