javascriptreact-nativephone-numberlibphonenumber

How to parse a number having zeros after "+" sign in javascript?


I have numbers saved in the given formats:

eg:

+060169034675
+003478596956
...
+000057465744

The libphonenumber-js library cannot parse this number, gives an error.

Now I want to delete the zeros after '+' sign, then it will be easy to parse.


Solution

  • You must try parseInt function which will return you number.

    console.log(parseInt("+0060169034675"));
     console.log("+"+parseInt("+0060169034675"));