In case you meant const a = 1,25; instead of const a = 1.25; , you are probably out of luck (Babel plugin at best).
If you meant const a = parseFloat('1,25'); instead of const a = parseFloat('1.25') , you can get there using string.replace or a regex (depending on your circumstances): const a = parseFloat('1,25'.replace(',', '.')); (which might not be the sanest solution available :D)
Hi Emil Moe. I think you can by overiding the Number prototype but I think it's not a good idea.
If you really want to use comas instead of dot notation you can write a service which replaces your comas by dots. You can use the .replace() function or .match() with the appropriate regex to achieve that.
Hope it helped.
Have a good one :)
Emil Moe
Senior Data Engineer
Sai Kishore Komanduri
Engineering an eGovernance Product | Hashnode Alumnus | I love pixel art
Hi, Emil!
If you're only concerned about the display format for the end users of your application, all you need to use is:
number.toLocaleString('da-DK'). I'm using the Danish (Denmark) locale string ('da-DK'); it will output the number in the format as you require —,for decimals, and.for thousands.For instance,
(33500.5).toLocaleString('da-DK')will return"33.500,5".Hope this helps! :)