How to Use Stringbuilder in Angular2

How to Use Stringbuilder in Angular2

I am doing an angular2 application and there I have to use StringBuilder. So I have to know How to use the string builder and how to append to it.

var sb = new StringBuilder();
var sResult = "";
$(arrayWidgets).each(function (index) {
    if (arrayWidgets[index] != "") {
        sb.append("<div class='EachWidget FL'>");
        sb.append("</div>");
    }
});

This is the code in Javascript

StringBuilder Code

var StringBuilder = function () { this.value = ""; };
StringBuilder.prototype.append = function (value) { this.value += value; };
StringBuilder.prototype.toString = function () { return this.value; };
2
Maya Lin-Takahashi
Author

Maya Lin-Takahashi

Maya is a hardware enthusiast who tests and reviews smart home devices, smartphones, wearables, and audio gear. She focuses on practical consumer value and build quality.