Javascript prototype property

Generally use the prototype property:

<span class="kwd">function</span> <span class="typ">YourObject</span><span class="pun">()</span>
<span class="pun">{</span>
    <span class="com">//</span>
<span class="pun">}</span>

<span class="typ">YourObject</span><span class="pun">.</span><span class="pln">prototype</span><span class="pun">.</span><span class="pln">yourMethod</span><span class="pun">=</span> <span class="kwd">function</span><span class="pun">()</span>
<span class="pun">{</span>
   <span class="com">//</span>
<span class="pun">}</span>

One thing I haven’t seen anyone mention yet is why you might want to use the prototype property over, say, object-literal notation: doing so ensures the function definition gets shared across all instances of the objects created from your function prototype, rather than once per instantiation.