G
Gregor Kofler
I've augmented string objects (not the prototype) and none of the
popular browsers ever complained. Until Chrome came along. Chrome won't
accept something like
String.prototype.foo = function() {
if (!this.bar) {
this.bar = [];
}
// this.bar stays always undefined
}
Trying a workaround I came across
String.prototype.bar = [];
String.prototype.foo = function() {
this.bar.push({
o: this,
p: "baz"
});
return this;
}
var x = "foo";
var y = "foo";
x.foo();
y.foo();
alert("".bar[0].o === "".bar[1].o);
yields false in "all" browsers. Chrome returns true.
Any comments on that?
Gregor
popular browsers ever complained. Until Chrome came along. Chrome won't
accept something like
String.prototype.foo = function() {
if (!this.bar) {
this.bar = [];
}
// this.bar stays always undefined
}
Trying a workaround I came across
String.prototype.bar = [];
String.prototype.foo = function() {
this.bar.push({
o: this,
p: "baz"
});
return this;
}
var x = "foo";
var y = "foo";
x.foo();
y.foo();
alert("".bar[0].o === "".bar[1].o);
yields false in "all" browsers. Chrome returns true.
Any comments on that?
Gregor