<object_name>.prototype.<method_or_property_name>= <value_or_function>;





var StringBuilder = function () {
   this.arr = new Array();
}







StringBuilder.prototype.AppendString = function (value) {
            this.arr.push(value);            
}







StringBuilder.prototype.ToStringValue = function () {
           return this.arr.join("");
}







var sb = new StringBuilder();
sb.AppendString("This");
sb.AppendString(" is");
sb.AppendString(" a");
sb.AppendString(" StringBuilder");
sb.AppendString(" Example");
alert(sb.ToStringValue());










<script type="text/javascript">
        var StringBuilder = function () {
            this.arr = new Array();
        }
        
        StringBuilder.prototype.AppendString = function (value) {
            this.arr.push(value);            
        }

        StringBuilder.prototype.ToStringValue = function () {
           return this.arr.join("");
       }
        
        var sb = new StringBuilder();
        sb.AppendString("This");
        sb.AppendString(" is");
        sb.AppendString(" a");
        sb.AppendString(" StringBuilder");
        sb.AppendString(" Example");
        alert(sb.ToStringValue());   
</script>



Posted By  -  Karan Gupta
 
Posted On  -  Thursday, August 30, 2012

Query/Feedback


Your Email Id  
 
Subject 
 
Query/FeedbackCharacters remaining 250