Trim in Javascript

TRIM IN JAVASCRIPT

 

JavaScript supports a large number of functions, the trim function is present in one of them, the trim is a JavaScript function that is used for the space removed from the start and end. This removes the beginning and end of the string's white space

 

JavaScript trim doesn't take any argument to call, it always returns a new string without any leading and trailing white space.

 

Example 1: -

//  TODO : DEFINE VARIABLE
  var x = “ gomehere      ”;  
 // TODO : REMOEV SPACE FROM LAST OF THE STRING
var x = x.trim();   
 // TODO : SEE RESULT AFTER JAVASCRIPT TRIM
console.log(x);   

Output

Gomehere

Example 2: -

 //  TODO : DEFINE VARIABLE

var x = “       gomehere”;
 // TODO : REMOEV SPACE FROM START OF THE STRING

var x = x.trim();
 // TODO : SEE RESULT AFTER JAVASCRIPT TRIM

console.log(x);

Output

Gomehere


About author

Author:- Mukesh Pant

Mukesh Pant

Founder of GOMEHERE and exploring new ideas in multiple areas like technology, programming, travel, sport, utility, and many more for the audience to solve their problems. Also, keep in touch by email mrpant90@gmail.com



3 Comments

Amanda Martines 5 days ago

Exercitation photo booth stumptown tote bag Banksy, elit small batch freegan sed. Craft beer elit seitan exercitation, photo booth et 8-bit kale chips proident chillwave deep v laborum. Aliquip veniam delectus, Marfa eiusmod Pinterest in do umami readymade swag. Selfies iPhone Kickstarter, drinking vinegar jean.

Reply

Amanda Martines 5 days ago

Exercitation photo booth stumptown tote bag Banksy, elit small batch freegan sed. Craft beer elit seitan exercitation, photo booth et 8-bit kale chips proident chillwave deep v laborum. Aliquip veniam delectus, Marfa eiusmod Pinterest in do umami readymade swag. Selfies iPhone Kickstarter, drinking vinegar jean.

Reply

Baltej Singh 5 days ago

Drinking vinegar stumptown yr pop-up artisan sunt. Deep v cliche lomo biodiesel Neutra selfies. Shorts fixie consequat flexitarian four loko tempor duis single-origin coffee. Banksy, elit small.

Reply

Marie Johnson 5 days ago

Kickstarter seitan retro. Drinking vinegar stumptown yr pop-up artisan sunt. Deep v cliche lomo biodiesel Neutra selfies. Shorts fixie consequat flexitarian four loko tempor duis single-origin coffee. Banksy, elit small.

Reply

Leave a Comments

Scroll to Top