Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

Adobe Summit 2023 [19th to 23rd March, Las Vegas and Virtual] | Complete AEM Session & Lab list

How can i condense in JavaScript?


Level 8


In some other scripts, we have the below syntax to ERASE all the left spaces or zeros & condenses finally, makes it a meaningful string with a good intendation,

SHIFT my_variable LEFT DELETING LEADING spaces/zeros,

do we have a EQUIVALENT code in JavaScript?

Thank you

2 Replies


Level 2


To remove leading space;

string.replace(/^\s+/, "");

To remove leading zero;


It's same as general javascript.



Level 10


I designed a macro for Designer ES2 (9.x) and ADEP Designer (10.x).

It looks for JavaScripts in a form template and beautifies them, means the script are formatted in that way a JavaScript should look like.

This also removes all unneccassary leading and trailing spaces.