user3014233
user3014233

Reputation:

Microsoft EDGE message: SCRIPT1006: Expected ')'

Error message only in edge browser, look like edge does not like default function parameter value flag = false, what is right way?

function func(flag = false)
{
  alert("Hate edges");
}

func();

Upvotes: 1

Views: 1910

Answers (1)

Sampson
Sampson

Reputation: 268344

Default parameter values are presently supported behind a flag in Microsoft Edge. To enable them, visit about:flags, and check Enable experimental JavaScript features.

If you'd like to use a feature like this, I'd encourage you to consider using a transpiler like Babel or TypeScript, which will produce ES5 compliant syntax for things.

For example, TypeScript yields the following:

function func(flag) {
    if (flag === void 0) { flag = false; }
    alert("Hate edges");
}
func();

Upvotes: 2

Related Questions