When a method depends on another method
<p>What is the best way to deal with the following situation in JavaScript.</p>

<p>I have three methods (<code>m1</code>, <code>m2</code>, <code>m3</code>) and the last one (<code>m3</code>) depends from the results of the others two (<code>m1</code>, <code>m2</code>).</p>

<p>In this way it works, but I am curious to know if there is a better way to write the code in this situation, especially for future developers that will read the code.</p>

<pre><code>var O = function () {
    this.p = 0;
}

O.prototype.makesomething = function () {
    var that = this;
    that.m1();
    that.m2();
    that.m3();
}

O.prototype.m1 = function () {O.p++}; // it changes the value O.p
O.prototype.m2 = function () {O.p++}; // it changes the value O.p
O.prototype.m3 = function () {return O.p}; // m3 depends by m1, m2 because it needs to get the update value of O.p
</code></pre>
