I'd like to know what you think of this approach to implementing mathematical functions in JavaScript. Rather then
Math.pow(base, exponent) wouldn't it be easier, and make more sense, to write
(base).pow(exponent)? It is really easy to create such methods.
Code: Select all
Number.prototype.pow = function(e) { return Math.pow(this, e); };
With this I could write:
Code: Select all
var base = 10;
base.pow(6);
(5).pow(2);
This feels more object oriented in a way, and it could be done with every math function.
If this was in a library or API of some kind how would you rate this? Is it good or bad? Explain why you think it is what you think it is.
Thanks for reading my brief and arguably uninteresting post.
