nested destructuring of undefined and default parameters

Aaron Frost aaronfrost at gmail.com
Tue Feb 5 05:32:08 PST 2013


I am trying to understand what should happen if you do a nested
destructuring of undefined, where the pattern has a default value included.
Here is an example of my question:

var foo = { bar : { baz : true } };
function readFoo({ bar: { baz="DEFAULT BAZ"} }){
    console.log(baz);
}
readFoo(foo); //true
readFoo(undefined); //what should happen here

Should the second call error because it can't find property baz of
undefined bar (undefined.baz)? Or should is assign the default because it
couldn't locate the value with no error? Possible third option?

--
AF
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20130205/6e52d539/attachment.html>


More information about the es-discuss mailing list