DenoDDeno
Powered by
BairdyB
Denoβ€’4y agoβ€’
2 replies
Bairdy

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).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);
},
Deno banner
DenoJoin
Chat about Deno, a modern runtime for JavaScript and TypeScript.
20,944Members
Resources
Recent Announcements

Similar Threads

Was this page helpful?

Similar Threads

SQLite null prototype
SebastianSSebastian / help
11mo ago
Abusing prototype CryptoKey in `node:crypto`
abiAabi / help
3y ago
how to use Untar without deprecated functions?
yoggydYyoggyd / help
3y ago
Using `Deno.FsFile.prototype.readable` with `Response`
csjhCcsjh / help
2y ago