what string literal is available in google apps script?

Looking for something in google apps script that does something similar to ES6 javascript.

Ss.main.getRange('C2').setValue('${Ss.main.getRange(2,2).getDisplayValue()}')

expected C2 cell to equal the value in B2. instead i get ${Ss.main.getRange(2,2).getDisplayValue()}


The current version of Apps Script does not support ES6 string literals (but that will change with the upcoming V8 upgrade, hopefully in the near future). In the meantime, you can leverage the Utilities.formatString() function.

Your sample code can be converted as follows:

Ss.main.getRange('C2').setValue(Utilities.formatString(
    "%s",
    Ss.main.getRange(2,2).getDisplayValue()
));

However, if all you need to do is convert the returned value to a string then you can use the getDisplayValue() call directly (since the function returns a string by default):

Ss.main.getRange('C2').setValue(Ss.main.getRange(2,2).getDisplayValue());