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

What ancient version of javascript is this?

Participant ,
Sep 24, 2024 Sep 24, 2024

I got the error:

Map does not have a constructor on this simple line:

copyMap = new Map();


Isnt map included since 10 years or so? id i do something wrong or do I really have to implement is myself?

TOPICS
Bug , Scripting , SDK
1.1K
Translate
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 , Sep 24, 2024 Sep 24, 2024

Adobe's ExtendScript is based on ECMAScript 3, from 1999. 

 

 

 

 

 

 

 

 

Translate
Community Expert ,
Sep 24, 2024 Sep 24, 2024

Hi @Lordrhavin , there’s no map object or maps collection. There are collections\objects like ObjectStyleExportTagMaps, StyleExportTagMaps, XMLExportMap, etc. Maybe some context would help, or you can search the API here:

https://www.indesignjs.de/extendscriptAPI/indesign-latest/#Application.html

Translate
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 24, 2024 Sep 24, 2024

Adobe's ExtendScript is based on ECMAScript 3, from 1999. 

 

 

 

 

 

 

 

 

Translate
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 26, 2024 Sep 26, 2024

I'm not sure how I managed to delete my mention of polyfills before hitting "Post." But no, I've found that we typically don't have to actually reimplement this kind of stuff ourselves. Someone else has most likely already done so - usually some years ago, in the name of maintaining backwards compatibility for older web browsers. Every single time I've thoughtlessly used something like map or indexOf, I've been able to find a perfectly functional polyfill in a few clicks. 

Translate
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 27, 2024 Sep 27, 2024

But no, I've found that we typically don't have to actually reimplement this kind of stuff ourselves.

 

https://community.adobe.com/t5/indesign-discussions/copying-page-content/td-p/14882538

Translate
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 24, 2024 Sep 24, 2024

You could also try UXP scripting. It's a bit more modern (uses Javascript 6) but still isn't quite at API parity with the old ExtendScript which most scripts are still written in.

Translate
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
Enthusiast ,
Jun 13, 2025 Jun 13, 2025

I just ported an admittedly pretty simple script from ExtendScript to UXP.

 

The first pitfall people are likely to hit is that the subscript operator, [], doesn't work for collections like paragraphs, as in

app.selection[0].paragraphs[0]
 
Only the selection is an array, so you have to say,
app.selection[0].paragraphs.item(0)

 

Beyond that, it worked fine. Just put

let { app } = require("indesign");
 
at the top of your script.
Translate
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 ,
Jun 14, 2025 Jun 14, 2025

There is some documentation on ES > UXP migration, e.g.:

 

https://developer.adobe.com/indesign/uxp/resources/migration-guides/extendscript/

Translate
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
Enthusiast ,
Jun 16, 2025 Jun 16, 2025
LATEST

Yep, thanks. That's where I discovered the information about the subscript operator not working anymore.

Translate
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