Different between object.propertyName and object["propertyName"] in Javascript
<p>I've been learning Js recently from "<a href="http://rads.stackoverflow.com/amzn/click/0596517742" rel="nofollow">JavaScript the Good Parts</a>", and according to my understanding </p>

<p><code>Object.propertyName</code> yields same result as <code>Object["propertyName"]</code>(Please correct me if I'm not right and describe the difference of the two).</p>

<p>I'm trying to augment the Function.prototype to make a <em>method</em> available to all functions as below:</p>

<pre><code>Function.prototype.method = function (name, func) {
            this.prototype[name]= func;
    };
</code></pre>

<p>And it's working fine.However, when I'm replacing the <code>this.prototype[name]</code> with <code>this.prototype.name</code>, it'll fail functioning as expected!</p>

<p>This is how I'm testing it:</p>

<pre><code> Number.method("myRoundFunction", function () {
        return Math[this &lt; 0 ? "ceil" : "floor"](this);
    });
    console.log((-10 / 3).myRoundFunction());
</code></pre>

<p>This shows the expected value (-3) when using <code>this.prototype[name]</code>, but </p>

<blockquote>
  <p>(-3.3333333333333335).myRoundFunction is not a function</p>
</blockquote>

<p>on changing it to <code>this.prototype.name</code></p>

<p>Could someone possibly clarify why this is happening?</p>

<p>Thanks in advance for any help.</p>
