Skip to main content
Participant
February 12, 2018
Answered

Map, Reduce and functional scripting

  • February 12, 2018
  • 1 reply
  • 2137 views

Hi all,

I've been writing scripts and was refactoring some code to utilize functional methods like (map, reduce, filter).

It appears that these are completely unsupported. Is this true? I couldn't find any confirmation either way, only that they appear not to work. I can't imagine why this would be the case.

Here is a trivial example of a script that fails to run:

var x = [4,9,16];

var y = x.map(Math.sqrt);

alert(y);

I get the following error: "x.map is not a function".

Best wishes,

Jake

Correct answer O2 Creative NZ

Its called Extendscript  (see ExtendScript - Wikipedia ) based on ECMA 3 AKA Javascipt 1999. Some methods you are used to may also work differently. If you install ExtendScript Toolkit, run it and then select HELP > Object Model Viewer you can browse all the built in Objects and see their methods/props etc.

It works, just no modern features. Polyfills from MDN help some.

1 reply

Participant
February 12, 2018

I'd still like some formal clarification, but adding my own Array.prototype.map definition "solved" the problem.

Is Adobe just running an ancient javascript engine?

O2 Creative NZCorrect answer
Inspiring
February 13, 2018

Its called Extendscript  (see ExtendScript - Wikipedia ) based on ECMA 3 AKA Javascipt 1999. Some methods you are used to may also work differently. If you install ExtendScript Toolkit, run it and then select HELP > Object Model Viewer you can browse all the built in Objects and see their methods/props etc.

It works, just no modern features. Polyfills from MDN help some.

Participant
February 26, 2025

Hi,

quote

It works, just no modern features. Polyfills from MDN help some.


By @O2 Creative NZ

I'm working with Babel, a polyfill transcriptor, and specifying "ie 6" (2001 browser) in "target" browser. Giving this snippet of code : 

thing= [1, 2, 3]
thing.map((x)=>x+2)

does indeed give me this.

truc = [1, 2, 3];
truc.map(function (x) {
  return x + 2;
});

These two snippets work in browser console, but I still get the same error as OP in Premiere Pro.
ExtendScript should have the map function if it were based on ECMA 3 right ?
Indeed, my source code comes from https://youtu.be/esBhotDXQg0?si=fl_uY2Xp-g42rKJ8s which is using map (see 4:18), scripts that works in his Premiere Pro (see 13:35), 4 years ago.

So no, I wouldn't say "it works" since it seems broken now, nor I would say that "map()", a 1999 function is a "modern feature"... 😅

How could I make it work for ExtendScript ?