String.trim Last updated: 13. Nov 2023
Removes spaces before and after a text in a string.
Parameters
This function takes no parameters
Returns
A "trimmed" string, where leading and ending spaces have been removed. Does not change the initial string object but returns a modified string.
Example
Code example (#JS)
#JS is mixed HTML (or other text file) with inline JavaScript with # starting and ending each inline statement.#{
/* Declare a text to trim */
var text = " hello ";
/* Remove leading and ending spaces */
text = text.trim();
/* Output contents of text variable */
if(text == "hello") write("OK!");
}#
Output
The #JS code above produces the output shown below:OK!