prototype dot functions. How?
How would I go about creating dot function that can be chained at the end of a number in Deno?
Example:
(2).toUSD() // returns $2.00
2 Replies
you would have to extend prototype of a Number, but please don't do that, you can just do
toUSD(2)
If https://github.com/tc39/proposal-call-this eventually gets implemented, you might be able to write
GitHub
GitHub - tc39/proposal-call-this: A proposal for a simple call-this...
A proposal for a simple call-this operator in JavaScript. - GitHub - tc39/proposal-call-this: A proposal for a simple call-this operator in JavaScript.