IE浏览器独现SCRIPT1006错误:ES6默认参数兼容修复求助
Hey there, let’s work through this IE-specific issue you’re facing. That SCRIPT1006: Expected ')' error popping up only in IE is 100% related to the browser’s lack of support for ES6 JavaScript features—specifically default function parameters in your code line.
The Root Cause
Your original code uses an ES6 shorthand for setting a default value to the ev parameter:
function dependanceLookup(_el, ev = false) { // ... existing logic }
Internet Explorer (all versions) doesn’t recognize this syntax—it expects parameters to be defined without the = value default assignment, hence the missing ) error at that position.
The ES5-Compatible Fix
Since you only have access to this specific line (and the plugin is paid with no full code access), modify the function to use ES5 syntax that IE understands:
function dependanceLookup(_el, ev) { ev = !!ev; // This replicates the original default false behavior // ... existing logic remains the same }
Here’s why this works:
- By removing
= falsefrom the parameter list, we’re using standard ES5 function declaration syntax that IE supports. - The line
ev = !!ev;converts theevparameter to a boolean value. Ifevisn’t passed to the function (i.e., it’sundefined),!!undefinedevaluates tofalse—exactly matching the original ES6 default value. For any truthy value passed in, it will staytrue, so existing functionality in other browsers won’t break.
This change will resolve the IE error while keeping the function’s behavior identical in all other modern browsers.
内容的提问来源于stack exchange,提问作者user6796243

