trim()

trim() enables the developer to remove any whitespace (any characters that represents a space) from the beginning and the end of a string.

trim() takes an input string as its argument and removes all whitespace from the beginning and the end of that string. If the string is a sentence with spaces between words then trim() will leave the whitespace between the words:

trim(‘  The cat sat on the mat   ’)

trim(‘  Spaceship  ’)

Would return the strings:

‘The cat sat on the mat’

‘Spaceship’

Adding the two strings together would produce the following string:

‘The cat sat on the matSpaceship’

 

Contact Us

Privacy Policy

Copyright © 2024 Querix, (UK) Ltd.