Welcome Dialog

Welcome to the Community!

We have a brand new look! Take a tour with us and explore the latest updates on Adobe Support Community.


Array.prototype functions undefined in After Effects scripts?

New Here ,
Aug 17, 2021 Aug 17, 2021

Copy link to clipboard

Copied

So, a script I was developing was working fine yesterday, but today, it seems like my Array built-in object is broken. I tried restarting After Effects to reset the environment, but it's still broken. So far, I've identified that "map", "includes", and "split" are broken, though "shift" is fine. I don't have any custom startup scripts.

 

I've attached a simple .txt file that demonstrates this error for me, though I'm guessing it would work normally. Just rename it to .jsx and run it yourself.

 

OS: MacOS Big Sur v11.4

AE: v18.4.0 build 41

TOPICS
Error or problem, Scripting

Views

31

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Aug 17, 2021 Aug 17, 2021

Copy link to clipboard

Copied

EDIT:

Whoops, "split" is a string function, it won't work anyway, ahahah.

Still, "map" and "includes" are both broken for me.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Aug 18, 2021 Aug 18, 2021

Copy link to clipboard

Copied

In general, you cannot expect Ae scripting to support all features of modern JavaScript.

After Effects scripting is using ExtendScript and ExtendScript implements the JavaScript language according to the ECMA-262 specification. This is a very old variant of JavaScript and it does not include features like Array.map, yet.

 

 

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Aug 18, 2021 Aug 18, 2021

Copy link to clipboard

Copied

LATEST

The worst difference I found so far is actually this one:

true || true && false

evaluates to "false" in After Effects ExtendScript, but to "true" in modern JavaScript.

Because After Effects reads it as

(true || true) && false

whereas modern JavaScript reads it as

true || (true && false)

 

So when writing logic statements, make sure to always set parenthesis to avoid trouble. And don't use minifiers like uglify.js which remove these parenthesis.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines