When we do mobile page, we often encounter numbers , And in the Safari These numbers will display the phone number by default in the browser , So we used the method of mending the hole to add <meta> label :

<meta name="format-detection" content="telephone=no">
The point of this tag is that numbers are not considered phone numbers , So it's all right O(∩_∩)O, But if it's a reservation call , So after adding this label , The order call becomes a number , You can't dial directly, so we came up with the idea of using thousands of digits to indicate numbers, so as to distinguish telephone numbers from numbers A thousand symbols

In the West , When it comes to big numbers , With every 3 The bits are separated by a space , The separating symbol is the English comma , Because in Chinese , The first 3 Is it “ thousand ”, therefore , This one in the numbers “ comma ” Also known as “ Thousand separator ”.

The reason why every 3 Bit to separate , It's about the reading in English , for instance : English 987,654,321 The pronunciation is : nine hundred and eighty-seven billion six hundred and fifty-four thousand three hundred and twenty-one.

The key numerical unit , Such as billion,thousand That's exactly where the thousandth separator is . It can be seen that this separation is complementary to Western numerical reading methods .

But for Chinese users , This style is an embarrassment . Our main unit of large value is “ ten thousand ” and “ Billion ”, If the segmentation is done according to this standard , It should be every 4 Bit to separate . therefore , When we first saw 3 When it comes to separating numbers , It must be strange that the way of separation is not in accordance with the routine .

 Is there a solution ;
Method 1 :

Method 1 : Using regular expressions


The grammar is as follows :


String(Number).replace(/(\d)(?=(\d{3})+$)/g, "$1,");

give an example :


String(123456789).replace(/(\d)(?=(\d{3})+$)/g, "$1,");
 Method 2 :

Method 2 : Use toLocaleString() Method


The grammar is as follows :


Number.toLocaleString('en-US');

give an example :


(123456789).toLocaleString('en-US');

The result is :123,456,789


For the Chinese scene ,toLocaleString('en-US') Medium 'en-US' Theoretically, it can be defaulted , That is, directly (123456789).toLocaleString() You can also get 123,456,789. But if your product may be used by overseas users , To be on the safe side , Keep it 'en-US'.


in addition , about IE edge Previous version ,Number.toLocaleString() Two decimal places will be added automatically , If it's not needed , You need to filter it out yourself .


Use the thousand separator ( comma ) Express web More articles about big numbers on the web

  1. Please use the thousand separator ( comma ) Express web Big numbers on the web

    Method 1 : Using regular expressions The grammar is as follows : String(Number).replace(/(\d)(?=(\d{3})+$)/g, "$1,"); give an example : String(12345678 ...

  2. JS Add a thousand separator to the number

    The original link of this article :https://www.jianshu.com/p/928c68f92c0c JavaScript Implement thousand separator It's a very common problem to convert an ordinary number to a number string with a thousand separator , Thousands of points ...

  3. js A thousand symbols | js Thousand separator | js Amount format

    js Thousand separator Thousand separator , It's actually a comma in a number . According to Western custom , People put a symbol in the number , In order to avoid too many digits and difficult to see its value . So people in numbers , Put a comma every three digits , That's the thousand separator , To make it easier ...

  4. Thousand separator (js Realization )

    Recently, I was asked by my colleagues js How to add thousands separator to long numbers , namely 1344444 ---> 13,444,444 This is a very common front-end interview question . It looks simple , At first I was too lazy to write . Think carefully , It's very logical , Implementation methods include ...

  5. golang Thousand separator

    The project requirements will be displayed in the form of thousands separator ( Such as the 1234567.89 Formatted as 1,234,567.89), and golang There is no such function in the standard library of . Omnipotent google Find a solution , can ...

  6. web Use... In web pages vlc Plug in play camera rtsp Streaming video

    May refer to : Use vlc The player does rtsp The server Use vlc The player plays rtsp video Use vlc Second development to do their own player vlc It's still very powerful , There are many ready-made secondary development interfaces , You don't need to configure too much to play on the client ...

  7. Web Recognition and extraction of dynamic data region in web page Dynamical Data Regions Identification and Extraction in Web Pages

    Web Recognition and extraction of dynamic data region in web page Dynamical Data Regions Identification and Extraction in Web Pages Web Recognition of dynamic data area in web page ...

  8. JS Round to two decimal places and add thousands of separator

    var a = "-123456789.078";a = (Math.round(a * 100) / 100).toFixed(2).toString().replace(/(\ ...

  9. Thousand separator , The audio volume increases ,transform Vertical center

    1. Recently, I have been working as a Yin Yang teacher on the official website of Japan , One of the functions is to get the number of appointments , The number of people on the design draft is like this 151,567,000, I think it's a bit troublesome to write by myself , So online copy Code , I've revised it a little bit . among , One thing to note is that : Function str ...

Random recommendation

  1. php Determine the type of request ajax、get still post type

    1. adopt PHP Get... In predefined variables XMLHttpRequest interpretation . First you have to use jquery or Js send out ajax request , adopt jquery Sent $.ajax, $.get or $.post Method to request ...

  2. Asp.net Mvc Modular development series ( Catalog )

    Modular development is very important , Modular development is a systematic problem , For this reason, I think it is necessary to write a series of articles to make it clear So why write a catalog ? firstly . It's a response to my commitment yesterday to write a new series of articles second . It's to write an outline first , ...

  3. android Multi thread Download Breakpoint continuation

    source : Netease cloud classroom Android The eighth homework exercise of geek class Exercise content : Multithreading asyncTask handler The principle of multi thread download First get the size of the target file , Then apply for a space on the disk to save the target file , And then ...

  4. HTML Add multimedia or music

    1, Add Multimedia <embed src=" Multimedia file address " width=" The width of Multimedia " height=" The height of Multimedia " autosta ...

  5. spring data jpa Specification Example

    /** * Encapsulate query criteria * * @param baseQueryDTO * @return */ private Specification<ActivityBase> getSpeci ...

  6. MVC3 Html.ActionLink

    The parameter text description is used below : linkText: The text displayed by the generated link   type :string actionName: The method of corresponding controller type :string routeValues: To the corresponding action Delivered ...

  7. machine learning --- Bag of words model for text feature extraction (Machine Learning Text Feature Extraction Bag of Words)

    Suppose there is a text :"I have a cat, his name is Huzihu. Huzihu is really cute and friendly. We are good frie ...

  8. adjustment Eclipse Chinese code font size

    Window-->preferences-->general-->appearence-->Colors and fonts Medium Basic Node selection text font,Edit once

  9. Linux Little knowledge translation - 「 Alias 」

    actually ,「 Alias 」 Used in a variety of situations . such as 「 Alias of command 」,「 The alias of the email address 」 wait . therefore , Say it alone 「 Alias 」 When , According to the occasion of not using , The meaning of the representative is also different . Generally speaking ,「 Alias 」 It means something similar . 「 Alias 」 My English ...

  10. Exception while invoking TaskListener: Exception while invoking TaskListener: null

    https://community.alfresco.com/thread/225041-exception-while-invoking-tasklistener-null Ok, so the p ...