If tutorials available on this website are helpful for you, please whitelist this website in your ad blocker😭 or Donate to help us ❤️ pay for the web hosting to keep the website running.
String trim() method की String के दोनों side से whitespace remove करता है। लेकिन यह original String को change नहीं करता है।
string.trim();
string | required : यह String variable है जिसमे से whitespace remove करना है।
Return Value : यह original String को whitespace remove करके return करता है।
File : js_string_trim.html
<!DOCTYPE html>
<html>
<body>
<script>
let str = " Hello World !. ";
document.write("Original Length : " + str.length);
/*now remove whitespace*/
let new_str = str.trim();
document.write("<br> After removing whitespace : " + new_str.length);
</script>
</body>
</html>
Original Length : 32 After removing whitespace : 14
Hi ! My name is Rahul Kumar Rajput. I'm a back end web developer and founder of learnhindituts.com. I live in Uttar Pradesh (UP), India and I love to talk about programming as well as writing technical tutorials and tips that can help to others.
Get connected with me. :) LinkedIn Twitter Instagram Facebook