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

Map, Reduce and functional scripting

New Here ,
Feb 12, 2018 Feb 12, 2018

Copy link to clipboard

Copied

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

TOPICS
Scripting

Views

1.9K
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

Explorer , Feb 12, 2018 Feb 12, 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.

Votes

Translate
Adobe
New Here ,
Feb 12, 2018 Feb 12, 2018

Copy link to clipboard

Copied

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?

Votes

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 12, 2018 Feb 12, 2018

Copy link to clipboard

Copied

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.

Votes

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 ,
Feb 26, 2025 Feb 26, 2025

Copy link to clipboard

Copied

LATEST

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 ?

Votes

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