D
Deno

help

prototype dot functions. How?

BBairdy1/29/2023
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
function toUSD(amount) {
// RETURN Something..
return new Intl.NumberFormat("en-US", {
style: "currency",
currency: "USD"
}).format(amount);
},
function toUSD(amount) {
// RETURN Something..
return new Intl.NumberFormat("en-US", {
style: "currency",
currency: "USD"
}).format(amount);
},
BBeast1/29/2023
you would have to extend prototype of a Number, but please don't do that, you can just do toUSD(2)
UUUnknown User1/29/2023
Message Not Public
Sign In & Join Server To View

Looking for more? Join the community!