ReactJs get string length
ReactJs get string length– We can use string length method to get the length of any string in reactjs. Here in this tutorial, we are going to explain how you can get the string length using native JavaScript length method. You can also use our line editor to edit and run the code online.
ReactJs get string Length Method Example
You can get length of any string in reactJs simply as below-
Example:
<script> function MyFunction() { var myStr = "tutorialsplane"; var result = myStr.length; return ( <p>Length of string "{myStr}" = {result}</p> ); } ReactDOM.render( <MyFunction />, document.getElementById('root') ); </script> |
Output of above example-
Advertisements