![]() |
JavaScript trim is a built-in function that is used to trim a string. A string is nothing but a group of characters. The trim ( ) removes whitespaces from both ends i.e. start and end of the string. We have to create an instance for a string class to invoke trim( ). It does not affect the original string. Syntax:str.trim()
Parameter:This method does not accept any parameter. Example 1: The trim() removes all whitespaces from the string and returns a new string. Javascript
Output
digitalvasanth Example 2: This example contains white spaces only at the end of string, and by using trim() we have eliminated those spaces. Javascript
Output
digitalvasanth |
Reffered: https://www.geeksforgeeks.org
Geeks Premier League |
Type: | Geek |
Category: | Coding |
Sub Category: | Tutorial |
Uploaded by: | Admin |
Views: | 13 |