• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
1

Missing methods in extendscript - differences between machines and installations

Explorer ,
Jan 24, 2021 Jan 24, 2021

Copy link to clipboard

Copied

Hey guys,

I have a strange case where several extendscript methods are missing on my main computer, where they are present in my beta installation, or on fresh installations on other computers. I can't explain the difference in possibilities. Any help is much appreciated.

What i've tried so far:
Uninstall / reinstall every adobe app

Uninstall / reinstall every adobe app with the adobe cleaner tool.

 

The difference can be seen when alerting a reflect of an array:

var myArr = [];
alert("reflect\r"+myArr.reflect.methods.join(","));

This results in the following alert in my main pc:

1.png
But this one on all other pcs/installations i've tried so far, including beta on my own main pc:

2.png
Notice the methods at the end: 
indexof, filter and map.

Any explanation would be most welcome. 
A potential fix would be perfect!
Thanks guys!

TOPICS
Scripting

Views

951

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

correct answers 1 Correct answer

Community Expert , Jan 29, 2021 Jan 29, 2021

ExtendScript is based on the ES3 which dos not come with Array.filter, Array.indexOf, etc, however some messy 3rd party scripts modify the prototype which results in extra or missing methods. If you're seeing these on fresh installs, then you must have a script somewhere, in your user / global scripts older and or in your startup scripts. 

Votes

Translate

Translate
Community Expert ,
Jan 26, 2021 Jan 26, 2021

Copy link to clipboard

Copied

If I remember correctly, filter and map are not part of ExtendScript by default.

If on a machine filter and map are available, I guess on this machine you have some scripts installed and executed on startup that add polyfills for these functions.

Mathias Möhl - Developer of tools like BeatEdit and Automation Blocks for Premiere Pro and After Effects

Votes

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
Explorer ,
Jan 26, 2021 Jan 26, 2021

Copy link to clipboard

Copied

That was my first idea as well, but indexOf, map AND filter are all present on multiple fresh installations. And by fresh in this case I mean fresh windows, wiped disks. Completely fresh computers. Straight out of the box, AE supports indexOf, filter and map there.

Votes

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
Community Expert ,
Jan 29, 2021 Jan 29, 2021

Copy link to clipboard

Copied

ExtendScript is based on the ES3 which dos not come with Array.filter, Array.indexOf, etc, however some messy 3rd party scripts modify the prototype which results in extra or missing methods. If you're seeing these on fresh installs, then you must have a script somewhere, in your user / global scripts older and or in your startup scripts. 

Votes

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
Explorer ,
Jan 29, 2021 Jan 29, 2021

Copy link to clipboard

Copied

This is what people keep telling me indeed - but just to specify this one more time to be sure - this happened on a machine that had windows installed from scratch on a formatted disk. There was nothing else on the computer - straight out the box. Your argument makes a lot of sense, but I still cannot explain this behavior on fresh windows.

That said however, i reinstalled windows again - formatted again, etc etc and now indexof, map and filter do not show. Im getting more confused by the minute - but it appears you are right. (I know you are right, but I was seeing counterintiitive test results -_-)

Votes

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
Community Expert ,
Jan 29, 2021 Jan 29, 2021

Copy link to clipboard

Copied

Strange, unless a built-in Adobe script was adding them which I doubt, but yes I wouldn't rely on those. If you need additional functions like that, check out Underscore or other helper libraries that are ES3 compatibile or write your own helper functions.

Votes

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
Explorer ,
Feb 01, 2021 Feb 01, 2021

Copy link to clipboard

Copied

Hey guys,

After asking around in the Beta forum as well, I've gotten a very interesting explanation that I wanted to share here as well.
As it turns out, Adobe's own Panels can add functionality to your codebase as well.

We received the following info:
Launching 'Learning' adds in Array. indexOf, which other jsx scripts can see and access.
Launching 'Libraries' panel adds Array.indexOfArray. filter, and Array .map (which again is accessible from your own scripts).
All of them will also add JSON.

So, depending on which panels you load in at start, or later, as soon as one of these are loaded you are adding functionality untill you close AE again. So, while it is true in my case that the extra methods were added by "external code", it was in fact "external code" from Adobe themselves, it appears.

Very interesting and explains a lot!

Votes

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
Explorer ,
Sep 15, 2024 Sep 15, 2024

Copy link to clipboard

Copied

Good find.
I think this should be marked as the correct answer.

Votes

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
Community Expert ,
Sep 21, 2024 Sep 21, 2024

Copy link to clipboard

Copied

Don't rely on these methods, they shouldn't have been leaked in the first place, and could dissapear at any time.

Votes

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
Explorer ,
Sep 21, 2024 Sep 21, 2024

Copy link to clipboard

Copied

LATEST

I've spend the better part of the day looking for other scripts or plug-ins exposing these methods, only to find out it is Adobe itself.  That's the reason I'm proposing this to be the correct answer. It's some build-in window panels of After Effects that's exposing these methods by mistake and not a third-party software.

As for relying on these "leaked" methods, I absolutely agree. Just don't 🙂

Votes

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 ,
Sep 01, 2023 Sep 01, 2023

Copy link to clipboard

Copied

Per Justin T's reply, because ExtendScript is based on an older or stripped down of Javascript, you may not have some functions. I added Array.map with this:

Array.prototype.map = function (callbackFn) {
    var arr = [];
    for (var i = 0; i < this.length; i++) {
        /* call the callback function for every value of this array and       push the returned value into our resulting array
        */
        arr.push(callbackFn(this[i], i, this));
    }
    return arr;
}

 

Votes

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
Community Expert ,
Sep 01, 2023 Sep 01, 2023

Copy link to clipboard

Copied

In AE, Premiere, and AME it's best to avoid polyfills (modifying prototypes) like this and instead use helper functions. More info on why here:

https://hyperbrew.co/blog/top-2-extendscript-mistakes-and-how-to-avoid-them/

Votes

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