I\'m trying to do this:
String.prototype.clear = function(){
alert(this.value);
this = \'\'; // I want to set value to \'\' here
}
var temp = \'Hell
You can create a class called MyMutableString like:
function MyMutableString(s) {
this.string = s;
this.clear = function() {
this.string = "";
}
}
Now you create an instance and use it like like:
var s = new MyMutableString("my str");
s.clear(); // makes string stored inside object `s` empty
console.log(s.string);