So if we can get past the "should you?" question ... does anyone know how to set the value of an integer in prototype?
Number.prototype.add = function(num){
var newVal = this.valueOf() + num;
this.valueOf(newVal);
return newVal;
}
var rad = 4001.23;
document.write(rad.add(10) + '<br/>' + rad);
You'll notice rad.add(10) returns the number contained in the variable "rad" plus 10, but I would really like to change the value of rad from within the prototype add function (something I know this.valueOf(newVal) does not accomplish).
Can this be done? If so, how?