A user defined function attached to String class in javascript
/* Javascript trim function attached to the String class*/
<script language = "javascript" type="text/javascript">
/* Javascript trim function attached to the String class*/
String.prototype.trim = function() {
return this.replace(/^\s+|\s+$/, '');
};
var str = "Actual:" + " Data ";
alert(str.trim() + "Here");
</script>