04-Apr-2023
.
Admin
Hello Friends,
Now let's see example of reactjs trim string method javascript example. In this article i will show you how to remove whitespace from both side in reactjs. The trim() method removes whitespace from both ends of a string. If you want to remove white space from both side in reactjs then you can use bellow example.
Here i will give simple example for trim function example in reactjs. In this example i will show simple and easy way to remove whitespace from both side So let's see the bellow example.
Example
import React from 'react'
export default class Home extends React.Component{
render(){
var myStr = " Hello World "; // space at both end
var myStrLength = myStr.length;
var myStr1 = myStr.trim();
var myStrLength1 = myStr1.length;
return(
<div>
<p>Befor Trim Length = {myStrLength} OR After Trim Length = {myStrLength1}</p>
</div>
);
}
}
It will help you....
#React.js