nested destructuring of undefined and default parameters

Aaron Frost aaronfrost at
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"} }){
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?

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the es-discuss mailing list