2

i'm getting this error

, or ) expected in Jquery function call in magento 2. I'm getting this error in custom jquery file.

I'm getting this following error in internet explorer browser. SCRIPT1006: Expected ')'

5
  • can you post the actual error in the browser console, It seems your code is all good Commented Jun 28, 2019 at 8:29
  • which editor use ??? Commented Jun 28, 2019 at 8:41
  • SCRIPT1006: Expected ')' @fmsthird Commented Jun 28, 2019 at 9:34
  • Phpstorm @RkRathod Commented Jun 28, 2019 at 9:35
  • check my answer Commented Jun 28, 2019 at 9:46

2 Answers 2

1

That is valid ES6 Javascript but Internet Explorer does not support ES6 (ECMAScript 2015), so you'll need to write the ES5 equivalent which looks something like this:

if (typeof entity === 'undefined') {
    entity = null;
}
3
  • @Ben_Crook . This is not about which version i'm using in editor. I'm getting this error in Internet explorer. Commented Jun 28, 2019 at 9:37
  • The same thing stands, you are writing ES6 Javascript when IE only supports ES5 Commented Jun 28, 2019 at 13:40
  • If you are supporting IE you cannot use default values on arguments, you need to do what I've done in my answer and manually check if a value has been assigned. So check if it's undefined and if so you set it to null. Commented Jun 28, 2019 at 13:40
1

Confige JavaScript language version In phpstrom

Go to Settings > Languages & Frameworks > JavaScript

Then change JavaScript language version to ECMAScript 6

From the table here you can see there is still very limited support for default parameters. If you want to use default parameters I suggest looking into Babel.

4
  • Error is not coming in Phpstorm after changing the version. How to resolve this error in Internet Explorer? Commented Jun 28, 2019 at 9:50
  • what error in Internet Explore ??? Commented Jun 28, 2019 at 9:52
  • I have updated my question. Please check. Commented Jun 28, 2019 at 9:57
  • updated my answer Commented Jun 28, 2019 at 10:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.