JSFiddle - React, Tailwind, and code Playground

JavaScript

function Text(text) {
    this.value = text;

    this.duplicate = function() { 
        this.value = this.value+this.value; 
        return this; 
    }
    
    this.bold = function() { 
        this.value = "<b>"+this.value+"</b>"; 
        return this; 
    }
}

var text = new Text('hello').duplicate().bold();
var text2 = new Text('hello2').duplicate().bold();

alert(text.value);