<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div><div>On Jul 16, 2008, at 10:14 PM, Kris Zyp wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">Arguably, some of the need for direct prototype access is</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">alleviated by providing the clone method.<span class="Apple-converted-space">  </span>However, there are still</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">plenty of other situations where it is useful.</div> </blockquote><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; min-height: 14px; "><br></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">I observe that __proto__ in SpiderMonkey- and Rhino-based JS is</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">mostly used for cases covered by Object.create, with a minority use-</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">case that we've discussed before initializing it to null in object</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">initialisers to make maps (dictionaries).</div> </blockquote><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; min-height: 14px; "><br></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">I am curious how Object.create covers this __proto__ use case of making<span class="Apple-converted-space"> </span></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">objects with a defined proto. Doesn't Object.create create a new object and<span class="Apple-converted-space"> </span></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">copy properties over?</div></blockquote><div><br></div>ES3.1 draft dated 15-July-08:</div><div><br></div><div><!--StartFragment--> <h4><span lang="EN-GB"><span class="msoIns"><ins cite="mailto:pratapL" datetime="2008-05-29T00:18">15.2.3.</ins></span><span class="msoIns"><ins cite="mailto:pratapL" datetime="2008-07-02T06:56">6</ins></span><span class="msoIns"><ins cite="mailto:pratapL" datetime="2008-07-15T18:57"><span style="mso-tab-count:1"> </span></ins></span><span class="msoIns"><ins cite="mailto:pratapL" datetime="2008-05-29T00:18">Object.</ins></span><span class="msoIns"><ins cite="mailto:pratapL" datetime="2008-06-30T19:59">create</ins></span><span class="msoIns"><ins cite="mailto:pratapL" datetime="2008-06-19T00:00"> </ins></span><span class="msoIns"><ins cite="mailto:pratapL" datetime="2008-05-29T00:18">(</ins></span><span class="msoIns"><ins cite="mailto:pratapL" datetime="2008-06-19T00:00"> </ins></span><span class="msoIns"><ins cite="mailto:pratapL" datetime="2008-05-29T00:18">O</ins></span><span class="msoIns"><ins cite="mailto:pratapL" datetime="2008-07-15T18:52"> [, Properties]</ins></span><span class="msoIns"><ins cite="mailto:pratapL" datetime="2008-06-19T00:00"> </ins></span><span class="msoIns"><ins cite="mailto:pratapL" datetime="2008-05-29T00:18">)</ins></span><span class="msoIns"><ins cite="mailto:pratapL" datetime="2008-06-18T23:56"><o:p></o:p></ins></span></span></h4><p class="M4"><span lang="EN-GB"><span class="msoIns"><ins cite="mailto:pratapL" datetime="2008-06-18T23:56">The </ins></span><span class="msoIns"><ins cite="mailto:pratapL" datetime="2008-06-30T20:00">create</ins></span><span class="msoIns"><ins cite="mailto:pratapL" datetime="2008-06-18T23:56"> method creates a new object with a specified prototype. When the static </ins></span><span class="msoIns"><ins cite="mailto:pratapL" datetime="2008-06-30T20:00">create </ins></span><span class="msoIns"><ins cite="mailto:pratapL" datetime="2008-06-18T23:56">method is called, the following steps are taken:<o:p></o:p></ins></span></span></p><p class="Alg4" style="margin-left:68.05pt;text-indent:0in;mso-list:l0 level1 lfo2; tab-stops:list 86.05pt"><span lang="EN-GB"><span style="mso-list:Ignore">1.<span style="font:7.0pt &quot;Times New Roman&quot;">                </span></span></span><span lang="EN-GB"><span class="msoIns"><ins cite="mailto:pratapL" datetime="2008-07-14T16:37">If Type(<i style="mso-bidi-font-style: normal">O</i>) is not Object throw a <b style="mso-bidi-font-weight:normal">TypeError </b>exception</ins></span><span class="msoIns"><ins cite="mailto:pratapL" datetime="2008-06-30T20:01">.</ins></span><span class="msoIns"><ins cite="mailto:pratapL" datetime="2008-06-18T23:56"><o:p></o:p></ins></span></span></p><p class="Alg4" style="margin-left:68.05pt;text-indent:0in;mso-list:l0 level1 lfo2; tab-stops:list 86.05pt"><span lang="EN-GB"><span style="mso-list:Ignore">2.<span style="font:7.0pt &quot;Times New Roman&quot;">                </span></span></span><span lang="EN-GB"><span class="msoIns"><ins cite="mailto:pratapL" datetime="2008-06-18T23:56">Create a new object </ins></span><span class="msoIns"><ins cite="mailto:pratapL" datetime="2008-06-18T23:57">as </ins></span><span class="msoIns"><ins cite="mailto:pratapL" datetime="2008-06-18T23:56">if </ins></span><span class="msoIns"><ins cite="mailto:pratapL" datetime="2008-06-30T20:04">by the expression </ins></span></span><b style="mso-bidi-font-weight:normal"><span lang="EN-GB" style="font-family:&quot;Courier New&quot;;mso-bidi-font-family:&quot;Courier New&quot;"><span class="msoIns"><ins cite="mailto:pratapL" datetime="2008-06-30T20:04">new Object()</ins></span></span></b><span lang="EN-GB"><span class="msoIns"><ins cite="mailto:pratapL" datetime="2008-06-30T20:04"> where </ins></span></span><b style="mso-bidi-font-weight:normal"><span lang="EN-GB" style="font-family:&quot;Courier New&quot;; mso-bidi-font-family:&quot;Courier New&quot;"><span class="msoIns"><ins cite="mailto:pratapL" datetime="2008-06-30T20:04">Object</ins></span></span></b><span lang="EN-GB"><span class="msoIns"><ins cite="mailto:pratapL" datetime="2008-06-30T20:04"> is the standard built-in constructor with that name</ins></span><span class="msoIns"><ins cite="mailto:pratapL" datetime="2008-06-18T23:56"><o:p></o:p></ins></span></span></p><p class="Alg4" style="margin-left:68.05pt;text-indent:0in;mso-list:l0 level1 lfo2; tab-stops:list 86.05pt"><span lang="EN-GB"><span style="mso-list:Ignore">3.<span style="font:7.0pt &quot;Times New Roman&quot;">                </span></span></span><span lang="EN-GB"><span class="msoIns"><ins cite="mailto:pratapL" datetime="2008-07-15T18:54">Call the standard built-in function Object.defineProperties with arguments Result(2) and <i style="mso-bidi-font-style:normal">Properties</i>.<o:p></o:p></ins></span></span></p><p class="Alg4" style="margin-left:68.05pt;text-indent:0in;mso-list:l0 level1 lfo2; tab-stops:list 86.05pt"><span lang="EN-GB"><span style="mso-list:Ignore">4.<span style="font:7.0pt &quot;Times New Roman&quot;">                </span></span></span><span lang="EN-GB"><span class="msoIns"><ins cite="mailto:pratapL" datetime="2008-07-14T16:35">S</ins></span><span class="msoIns"><ins cite="mailto:pratapL" datetime="2008-06-18T23:56">et the </ins></span><span class="msoIns"><ins cite="mailto:pratapL" datetime="2008-06-30T20:06">internal </ins></span><span class="msoIns"><ins cite="mailto:pratapL" datetime="2008-06-18T23:56">[[Prototype]] property of Result(2) to Result(</ins></span><span class="msoIns"><ins cite="mailto:pratapL" datetime="2008-06-30T20:06">1</ins></span><span class="msoIns"><ins cite="mailto:pratapL" datetime="2008-06-18T23:56">).<o:p></o:p></ins></span></span></p><p class="Alg4" style="margin-top:0in;margin-right:0in;margin-bottom:6.0pt; margin-left:.95in;text-indent:0in;mso-list:l0 level1 lfo2;tab-stops:list 86.05pt"><span lang="EN-GB"><span style="mso-list:Ignore">5.<span style="font:7.0pt &quot;Times New Roman&quot;">                </span></span></span><span lang="EN-GB"><span class="msoIns"><ins cite="mailto:pratapL" datetime="2008-06-18T23:58">Retu</ins></span><span class="msoIns"><ins cite="mailto:pratapL" datetime="2008-07-02T13:48">r</ins></span><span class="msoIns"><ins cite="mailto:pratapL" datetime="2008-06-18T23:58">n Result(</ins></span><span class="msoIns"><ins cite="mailto:pratapL" datetime="2008-07-15T18:56">4</ins></span><span class="msoIns"><ins cite="mailto:pratapL" datetime="2008-06-18T23:58">).</ins></span><span class="msoIns"><ins cite="mailto:pratapL" datetime="2008-06-30T20:07"><o:p></o:p></ins></span></span></p><p class="Alg4" style="margin-top:0in;margin-right:0in;margin-bottom:6.0pt; margin-left:.95in;text-indent:0in;mso-list:l0 level1 lfo2;tab-stops:list 86.05pt"><span class="Apple-style-span" style="text-decoration: underline;"><br></span></p> <!--EndFragment--> </div><div><blockquote type="cite"><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "> __proto__ allows objects with existing properties to<span class="Apple-converted-space"> </span></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">have their proto defined in constant time, but isn't Object.create still<span class="Apple-converted-space"> </span></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">O(n), with n being the number of properties?<br></div> </blockquote><br></div><div>Object.create allows creation of a new Object instance with a designated prototype object initializing [[Prototype]].</div><div><br></div><div>/be</div><br></body></html>