0

Keeping things simple here, consider this modern vanilla JS code:

function foo(bar, baz=1){
    ...

The use of default arg settings (baz) is pretty simple and expected. Mozilla says not a problem. Is there something in best practice regarding default params in JS I never learned in the 15+ years?

My IDE (JetBrains) can not hang with the code, yet my apps are working fine. Is there a reason why this is throwing errors or is my IDE in error? See screen shot of the validation error.

enter image description here

and Firefox Dev is fine with the syntax:

enter image description here

thanks in advance.

LazyOne
  • 158,824
  • 45
  • 388
  • 391
Marc
  • 1,895
  • 18
  • 25
  • 1
    Perhaps change `JavaScript language version` to match one that supports it: https://www.jetbrains.com/help/webstorm/2016.3/javascript.html – LazyOne Feb 06 '17 at 19:58

1 Answers1

0

For ES6 this is completely fine. See Set a default parameter value for a JavaScript function.

May be you need to say JetBrain that you are using ES6, this is working only in your browsers that support some subset of ES6. Check the compatibility list.

Community
  • 1
  • 1
laser
  • 570
  • 4
  • 20
  • This app is very much ES6 thankfully. As a Python guy my skin crawls when I have to do JS work. – Marc Feb 06 '17 at 20:54