97
rated 0 times
[
99]
[
2]
/ answers: 1 / hits: 20984
/ 14 Years ago, mon, february 28, 2011, 12:00:00
What is going on here? Just when I thought I knew JS inside and out, this gem comes up.
String.prototype.doNothing = function() {
return this;
};
alert(typeof 'foo'.doNothing()) // object
alert(typeof 'foo') // string
This is breaking some things that expect a string, such as jQuery's .text(str)
method.
More From » javascript