Skip to main content
Participant
July 15, 2022
Answered

ExtendScript

  • July 15, 2022
  • 4 replies
  • 876 views

howdy,

what version of javascript is used by extendscript?

wonder if variable resolution in string literals is support, e.g.

var _name = 'Dude'; alert(`howdy ${_name}`);

cheers,

PJ

This topic has been closed for replies.
Correct answer Peter Kahrel

Well, Patrick didn't say he was interested in localisation, all he wanted was to use a variable in s string. Seems to me that all he needs is

var _name = 'Dude'; alert('howdy ' + _name);

4 replies

Community Expert
July 17, 2022

Hi @Patrick Jaeger,

As has already been pointed out by other participants of the discussion, Extendscript is based on a very old standard so such mordern features are not available to it. However for your particular example we have a method that works almost like it. The method is localize, see the documentation at the following link

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

So your code sample could be rewritten as following

var _name = 'Dude'; alert(localize("howdy %1", _name));

-Manan

-Manan
Peter Kahrel
Community Expert
Peter KahrelCommunity ExpertCorrect answer
Community Expert
July 18, 2022

Well, Patrick didn't say he was interested in localisation, all he wanted was to use a variable in s string. Seems to me that all he needs is

var _name = 'Dude'; alert('howdy ' + _name);
Community Expert
July 21, 2022

Hi @Peter Kahrel,

Frankly speaking I have never used the localise method for localisation nor do I have any idea how that would work(would be great if you could share some examples for it). The reason I suggested this method was due to its capability to mimic the template literals of modern JS, specifically it's string interpolation functionality. String interpolation of all things make long strings intersperesed with results of expressions a lot easier to read. As far as I understood that is what the OP is after, even though the example used was a simplistic one and hence my suggestion. See the following

String interpolation

-Manan

-Manan
m1b
Community Expert
Community Expert
July 15, 2022

And here are the basic Extendscript docs. Code like it's 1999!

- Mark

rob day
Community Expert
Community Expert
July 15, 2022
brian_p_dts
Community Expert
Community Expert
July 15, 2022

ECMA 3. So most modern JS global functions are not available.