trims the white space from the left and right side of the string
trim() function இங்கு நாம் கொடுக்கும் string இல் starting மற்றும் ending இல் ஏதுனும் whitespaces இருந்தால் அதனை remove செய்கிறது
trim() Function in Javascript
trim() function இங்கு நாம் கொடுக்கும் string இல் starting மற்றும் ending இல் ஏதுனும் whitespaces இருந்தால் அதனை remove செய்கிறது.
str.trim()
Example1
<script>
var input = " Success is a journey not a destination ";
var res = input.trim();
document.writeln(res);
</script>
மேலே உள்ள Example1-ஐ கவனிக்கவும் இங்கு input என்ற variable இல் " Success is a journey not a destination " என்ற string value ஆனது store செய்யபட்டுள்ளது. இங்கு நன்றாக கவனிக்கவும் string இன் ஆரம்பம் மற்றும் இறுதியில் whitespaces கள் உள்ளன. input.trim() function இருபுறமும் உள்ள whitespaces ஐ remove செய்து Success is a journey not a destination என்ற output ஐ கொடுக்கிறது.
Success is a journey not a destination
Example2
<script>
var data = "Success only comes to those who dare to attempt ";
var res = data.trim();
document.writeln(res);
</script>
மேலே உள்ள Example2-ஐ கவனிக்கவும் இங்கு data என்ற variable இல் "Success only comes to those who dare to attempt " என்ற string value ஆனது store செய்யபட்டுள்ளது. இங்கு data.trim() என்ற function பயன்படுத்தபடுகிறது, இங்கு string இன் வலது புறத்தில் whitespaces கள் உள்ளன. data.trim() function இந்த whitespaces ஐ remove செய்து Success only comes to those who dare to attempt என்ற output ஐ கொடுக்கிறது.
Success only comes to those who dare to attempt