Answer
Workflow/BPA script tasks run on Camunda's underlying JavaScript engine (Nashorn, tied to the Java version in use), which fully supports ECMAScript 5.1 but only partially supports ECMAScript 6 — features like proper let/const block scoping, native Promises, and JS modules aren't fully supported, which is why some ES6-era methods and syntax either fail outright or behave inconsistently; stick to ES5.1-era JavaScript syntax and built-in methods (like indexOf() instead of includes()/findIndex(), and var instead of let/const) for reliable script-task behavior.