ToLocaleString () does not work in Safari browser

I used the toLocaleString() method to enter a comma in `javascript. But the problem is that the IE browser and chrome work correctly, with the exception of the Safari browser. I delete the cache several times, but it still doesn’t work. You can help?;)

 var test = 12300; console.log('test:'+test.toLocaleString()); // 12,300 in IE,Chrome // 12300 in Safari 
+6
source share
1 answer

The problem is that number.toLocaleString runs differently in different browsers. In Safari, he chooses not to display using the user-friendly formatting we are used to. It is supported on safari, but its implementation is different from IE, Chrome, or Firefox. See this link: http://forums.asp.net/t/2031925.aspx?toLocaleString+function+is+inconsistent+with+browser+

In addition, Safari does not support using the locale parameter with toLocaleString if you tried to set this: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toLocaleString

+14
source

Source: https://habr.com/ru/post/983348/


All Articles