Are patterns in parameter declarations irrefutable? In other words, given: function foo({ opt1 }) { return opt1 }
What happens if we call foo()? 1. An exception is thrown 2. undefined is returned I’d expect (2). If opt1 had a default value, I’d expect that value to be returned. What happens if we call foo({})? 1. An exception is thrown 2. undefined is returned I’m asking, because I’ve seen the pattern function foo({ opt1 = 3 } = {}) { return opt1 } If explicitly marking something as irrefutable is necessary, I’d prefer: function foo({ opt1 = 3 }?) { return opt1 } It’s a bit of a shame that destructuring and parameter declarations diverge, but I guess it can’t be helped. Axel -- Dr. Axel Rauschmayer a...@rauschma.de home: rauschma.de twitter: twitter.com/rauschma blog: 2ality.com
_______________________________________________ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss