Page 1 of 1

Cannot use "for-of" syntax and "forEach"

Posted: December 4th, 2022, 1:59 am
by SolidBlock

If I use `for-of` syntax in my script, the IDE identifies it correctly, but AE thinks it as a syntax error.
Also, if I use `forEach` with lambda instead, AE says "> has no value". If I use `forEach` with anonymous function syntax, AE says "forEach is undefined".

Also, I cannot use `includes`, which is a method in `Array`.
So what syntax should I use instead?


Re: Cannot use "for-of" syntax and "forEach"

Posted: December 11th, 2022, 11:51 am
by zlovatt

Extendscript is a version of Javascript from 1999, and so you're limited to the features available in ECMA3.

What you'll need to use is a for loop:

Code: Select all

for (var i = 0; i < items.length; i++) {
  var item = items[i];
  ...
}