"Exception: parameter(s) with default followed by parameter without default"

David Bruant bruant.d at gmail.com
Wed Oct 10 06:19:46 PDT 2012


Hi,

I've tried the following on Firefox:

  function f(a, b = 34, c){
      console.log('b', b)
  }

  f(1, undefined, 43)

and got "Exception: parameter(s) with default followed by parameter without
default"
It seems intentional, but I wonder why it's been decided this way.

It seems that default values for parameters "in the middle" can be useful
for older code base where parameters haven't been organized in prevision of
default value without requiring a refactoring involving switching parameter
order for all calls.

David

function f(a, b = 34, c){




    console.log('b', b)
}

f(1, undefined, 43)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20121010/8224f8f1/attachment.html>


More information about the es-discuss mailing list