<div dir="ltr">Don't you just mean the following:<div><br></div><div>```</div><div><span style="font-family:Calibri,"Slate Pro",sans-serif,sans-serif;font-size:medium">const {abc, xyz, qnc: {awj}} = obj;</span><br></div><div><span style="font-family:Calibri,"Slate Pro",sans-serif,sans-serif;font-size:medium">```</span></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Oct 25, 2017 at 12:22 AM, Sebastian Malton <span dir="ltr"><<a href="mailto:sebastian@malton.name" target="_blank">sebastian@malton.name</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="background-color:rgb(255,255,255);background-image:initial;line-height:initial"><div id="m_277605400857972113response_container_BBPPID" style="outline:none;font-size:initial;font-family:"Calibri","Slate Pro",sans-serif,"sans-serif"" dir="auto"> <div name="BB10" dir="auto" style="width:100%;padding:initial;font-size:initial;text-align:initial;background-color:rgb(255,255,255)"> This could also be extended to help with cleansing objects.</div><div name="BB10" id="m_277605400857972113BB10_response_div_BBPPID" dir="auto" style="width:100%;padding:initial;font-size:initial;text-align:initial;background-color:rgb(255,255,255)"><br></div><div name="BB10" id="m_277605400857972113BB10_response_div_BBPPID" dir="auto" style="width:100%;padding:initial;font-size:initial;text-align:initial;background-color:rgb(255,255,255)">const abc = {cde, def, efg} = obj;</div><div name="BB10" id="m_277605400857972113BB10_response_div_BBPPID" dir="auto" style="width:100%;padding:initial;font-size:initial;text-align:initial;background-color:rgb(255,255,255)"><br></div><div name="BB10" id="m_277605400857972113BB10_response_div_BBPPID" dir="auto" style="width:100%;padding:initial;font-size:initial;text-align:initial;background-color:rgb(255,255,255)">Would create an object abc with only those three fields in it.</div>                                                                                                                                      <div name="BB10" dir="auto" style="width:100%;padding:initial;font-size:initial;text-align:initial;background-color:rgb(255,255,255)"> <br style="display:initial"></div>                            <div id="m_277605400857972113blackberry_signature_BBPPID" name="BB10" dir="auto">     <div name="BB10" dir="auto" style="padding:initial;font-size:initial;text-align:initial;background-color:rgb(255,255,255)"></div> </div></div><div id="m_277605400857972113_original_msg_header_BBPPID" dir="auto">                                                                                                                                             <table width="100%" style="background-color:white;border-spacing:0px;display:table;outline:none"> <tbody><tr><td colspan="2" style="padding:initial;font-size:initial;text-align:initial;background-color:rgb(255,255,255)">                           <div style="border-right:none;border-bottom:none;border-left:none;border-top:1pt solid rgb(181,196,223);padding:3pt 0in 0in;font-family:Tahoma,"BB Alpha Sans","Slate Pro";font-size:10pt">  <div id="m_277605400857972113from"><b>From:</b> <a href="mailto:sebastian@malton.name" target="_blank">sebastian@malton.name</a></div><div id="m_277605400857972113sent"><b>Sent:</b> October 24, 2017 2:51 PM</div><div id="m_277605400857972113to"><b>To:</b> <a href="mailto:es-discuss@mozilla.org" target="_blank">es-discuss@mozilla.org</a></div><div id="m_277605400857972113subject"><b>Subject:</b> Extend Object Dereferencing</div></div></td></tr></tbody></table><div style="border-right:none;border-bottom:none;border-left:none;border-top:1pt solid rgb(186,188,209);display:block;padding:initial;font-size:initial;text-align:initial;background-color:rgb(255,255,255)"></div> <br> </div><div><div class="h5"><div name="BB10" dir="auto" style="background-image:initial;line-height:initial;outline:none"><div><div id="m_277605400857972113response_container_BBPPID" dir="auto"> <div id="m_277605400857972113BB10_response_div_BBPPID" dir="auto" style="width:100%"> Currently you can do the following </div><div id="m_277605400857972113BB10_response_div_BBPPID" dir="auto" style="width:100%"><br></div><div id="m_277605400857972113BB10_response_div_BBPPID" dir="auto" style="width:100%">const {abc, xyz, qnc} = obj;</div><div id="m_277605400857972113BB10_response_div_BBPPID" dir="auto" style="width:100%"><br></div><div id="m_277605400857972113BB10_response_div_BBPPID" dir="auto" style="width:100%">However if you want to go more than one level deep then you have to do it again for each level.</div><div id="m_277605400857972113BB10_response_div_BBPPID" dir="auto" style="width:100%"><br></div><div id="m_277605400857972113BB10_response_div_BBPPID" dir="auto" style="width:100%">I therefore propose the ability to do the following </div><div id="m_277605400857972113BB10_response_div_BBPPID" dir="auto" style="width:100%"><br></div><div id="m_277605400857972113BB10_response_div_BBPPID" dir="auto" style="width:100%"><div id="m_277605400857972113BB10_response_div_BBPPID" dir="auto" style="font-family:'calibri','slate pro',sans-serif,sans-serif;width:380px">const {abc, xyz, <a href="http://qnc.awj" target="_blank">qnc.awj</a>} = obj;</div><div id="m_277605400857972113BB10_response_div_BBPPID" dir="auto" style="font-family:'calibri','slate pro',sans-serif,sans-serif;width:380px"><br></div><div id="m_277605400857972113BB10_response_div_BBPPID" dir="auto" style="font-family:'calibri','slate pro',sans-serif,sans-serif;width:380px">And this would create the variables 'abc'', 'xyz', 'awj' with the values from obj. If qnc is not present then an undefined dereference exception would be thrown. </div><div id="m_277605400857972113BB10_response_div_BBPPID" dir="auto" style="font-family:'calibri','slate pro',sans-serif,sans-serif;width:380px"><br></div><div id="m_277605400857972113BB10_response_div_BBPPID" dir="auto" style="font-family:'calibri','slate pro',sans-serif,sans-serif;width:380px">This could also be extended with the proposed '?.' notation to go even deeper safely. </div></div>                            <div id="m_277605400857972113blackberry_signature_BBPPID" dir="auto">     <div id="m_277605400857972113_signaturePlaceholder_BBPPID" dir="auto"></div> </div></div></div></div></div></div></div><br>______________________________<wbr>_________________<br>
es-discuss mailing list<br>
<a href="mailto:es-discuss@mozilla.org">es-discuss@mozilla.org</a><br>
<a href="https://mail.mozilla.org/listinfo/es-discuss" rel="noreferrer" target="_blank">https://mail.mozilla.org/<wbr>listinfo/es-discuss</a><br>
<br></blockquote></div><br></div>