JSFiddle - React, Tailwind, and code Playground
JavaScript
function Anything( str ) {
this.str = str;
this.length = str.length;
}
Anything.prototype = new String;
Anything.prototype.toString = Anything.prototype.valueOf = function() {
return this.str;
};
var anything = new Anything("useless");
console.log( anything == "useless");
console.log( anything.charAt(0) === "u" );
console.log( anything.substr(0, 3) === "use" );
console.log( anything.toUpperCase() === "USELESS" );
console.log( anything instanceof String );