I'm trying to do this:
String.prototype.clear = function(){
alert(this.value);
this = ''; // I want to set value to '' here
}
var temp = 'Hello';
temp.clear();// After this step temp should be ''
But I'm getting invalid left hand assignment error. and I found this question as reference, but it's not really what I want.
I also find out that 'this' is Immutable.
So, is there any way to do my task? I'm not using it any where. Just playing around.
Thanks.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…