About 50 results
Open links in new tab
  1. How can I convert a string to an integer in JavaScript?

    There are two main ways to convert a string to a number in JavaScript. One way is to parse it and the other way is to change its type to a Number. All of the tricks in the other answers (e.g., unary plus) …

  2. What's the fastest way to convert String to Number in JavaScript?

    Oct 12, 2012 · Also, you might consider including string literal floats in the test for general comparison. My guess is that it may change the order in some cases because string to float conversion is …

  3. JavaScript string and number conversion - Stack Overflow

    Below is a very irritating example of how JavaScript can get you into trouble: If you just try to use parseInt() to convert to number and then add another number to the result it will concatenate two …

  4. What's the best way to convert a number to a string in JavaScript ...

    None of the answers I see at the moment correctly convert -0 to "-0". Note that -0..toString() might appear to work, but it's working by converting 0 to "0", then applying the minus sign to it, actually …

  5. What is the most efficient way to convert a string to a number?

    2 What would be the most efficient and safe method to convert a Decimal Integer String to a number in a time-critical loop or function where there are thousands (sometimes 100's thousands) of varying …

  6. Javascript to convert string to number? - Stack Overflow

    20 This question already has answers here: How can I convert a string to an integer in JavaScript? (32 answers)

  7. type conversion - how to convert number to string in JavaScript ...

    Jan 7, 2023 · Seems that var str = '' + num is the fastest way to convert a number to a string (num being the number variable).

  8. How can I parse a string with a comma thousand separator to a number?

    I have 2,299.00 as a string and I am trying to parse it to a number. I tried using parseFloat, which results in 2. I guess the comma is the problem, but how would I solve this issue the right way? ...

  9. javascript - How do I convert String to Number according to locale ...

    Sep 3, 2014 · I wrote a utility function that dynamically detect thousands and decimal separators by using JavaScript's toLocaleString method on an example number. It then normalizes the input string …

  10. Convert negative number in string to negative decimal in JavaScript ...

    Oct 3, 2020 · I have a string : "-10.456" I want to convert it to -10.465 in decimal (using JavaScript) so that I can compare for greater than or lesser than with another decimal number. Regards.