Skip to content

Number.prototype.toLocaleString() on currencies #21749

@aliismayilov

Description

@aliismayilov
  • Version: v10.6.0
  • Platform: Darwin Alis-MacBook-Pro.local 17.6.0 Darwin Kernel Version 17.6.0: Tue May 8 15:22:16 PDT 2018; root:xnu-4570.61.1~1/RELEASE_X86_64 x86_64
  • Subsystem:

I've noticed an inconsistency between the docs and the output of Number.prototype.toLocaleString() when using it to format the currencies.

https://nodejs.org/api/intl.html points me to https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toLocaleString which describes the output as following:

var number = 123456.789;
console.log(number.toLocaleString('de-DE', { style: 'currency', currency: 'EUR' }));
// → 123.456,79 €

which is correct, if I try it on Chrome. But if I try it on Node v10.6.0 repl, I get the following:

> var number = 123456.789;
undefined
> console.log(number.toLocaleString('de-DE', { style: 'currency', currency: 'EUR' }));
€123,456.79
undefined

the difference being the € sign's position. Also, on the same platform, I get the following output on Node v8.11.1 (current LTS):

> var number = 123456.789;
undefined
> console.log(number.toLocaleString('de-DE', { style: 'currency', currency: 'EUR' }));
 123,456.79
undefined

notice the extra whitespace after the euro sign.

Metadata

Metadata

Assignees

No one assigned

    Labels

    i18n-apiIssues and PRs related to the i18n implementation.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions