I have the following:
var version = [0,3,0];
// Override the version toString method.
version.__proto__.toString = function() {
return this.join('.');
};
Which does the following
version.toString => '0.3.0'
JSlint moans that __proto__
is a reserved name - which is correct.
I assume I am overloading incorrectly.
I do not want to
Array.prototype.toString
as that'll override all arrays to replace , with .?
Just set the method on the array directly:
var version = [0,3,0];
// Override the version toString method.
version.toString = function() {
return this.join('.');
};
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With