<div><div dir="auto">Sure Sebastian. </div><br><div class="gmail_quote"><div>On Fri, 16 Feb 2018 at 3:59 AM, Sebastian Malton <<a href="mailto:sebastian@malton.name">sebastian@malton.name</a>> wrote:<br></div><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_729944607548427409response_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 would be redundant because of the `?.` operator once it gets merged</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_729944607548427409blackberry_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)"><p>Sebastian Malton </p></div> </div></div><div id="m_729944607548427409_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_729944607548427409from"><b>From:</b> <a href="mailto:vikashagrawal1990@gmail.com" target="_blank">vikashagrawal1990@gmail.com</a></div><div id="m_729944607548427409sent"><b>Sent:</b> February 15, 2018 5:27 PM</div><div id="m_729944607548427409to"><b>To:</b> <a href="mailto:es-discuss@mozilla.org" target="_blank">es-discuss@mozilla.org</a></div><div id="m_729944607548427409subject"><b>Subject:</b> Proposal: Object.path([ ... ], defaultValue)</div></div></td></tr></tbody></table> <br> </div></div><div style="background-color:rgb(255,255,255);background-image:initial;line-height:initial"><div name="BB10" dir="auto" style="background-image:initial;line-height:initial;outline:none"><div>Hello Everyone, <div><div><br></div><div>It is a lot of times that we see `x is not a property of undefined` and to solve this we have to resort to &&, something like -> data && <a href="http://data.childData" target="_blank">data.childData</a> && <a href="http://data.childData.innerDataArray" target="_blank">data.childData.innerDataArray</a> && <span style="color:rgb(34,34,34);font-family:'arial',sans-serif;font-size:small;font-style:normal;font-weight:400;letter-spacing:normal;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);float:none;display:inline"><a href="http://data.childData.innerDataArray.length" target="_blank">data.childData.innerDataArray.length</a> > 0 whiich is quiet verbose. </span></div></div><div><span style="color:rgb(34,34,34);font-family:'arial',sans-serif;font-size:small;font-style:normal;font-weight:400;letter-spacing:normal;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);float:none;display:inline"><br></span></div><div><span style="color:rgb(34,34,34);font-family:'arial',sans-serif;font-size:small;font-style:normal;font-weight:400;letter-spacing:normal;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);float:none;display:inline">I suggest, we should add a utility method like <a href="http://Object.path" target="_blank">Object.path</a>, which takes an array of strings and returns the value from a given nested object. Also, this can take a second argument which will be a default value if not found. </span></div><div><span style="color:rgb(34,34,34);font-family:'arial',sans-serif;font-size:small;font-style:normal;font-weight:400;letter-spacing:normal;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);float:none;display:inline"><br></span></div><div>This is inspired by path and pathOr as implemented in <a href="http://ramdajs.com/docs/#path" target="_blank">http://ramdajs.com/docs/#path</a></div><div><br></div><div>Regards</div><div>~Vikash</div></div>
</div></div></blockquote></div></div>