About 192,000 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., …

  2. javascript - How can I check if a string is a valid number? - Stack ...

    If someone wants to know if a string contains a number, it seems to me that they would want to know if it contains a number, and 1e+30 is a number. Certainly if I were testing a string for a …

  3. JavaScript string and number conversion - Stack Overflow

    Here are some things you might see that take advantage of the way JavaScript deals with strings and numbers. Personally, I wish JavaScript had used some symbol other than + for string …

  4. Check whether variable is number or string in JavaScript

    Aug 20, 2009 · Does anyone know how can I check whether a variable is a number or a string in JavaScript?

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

    According to this benchmark it's the fastest way to convert a Number to String in Firefox 58 even though it's slower than " + num in the popular browser Google Chrome.

  6. html - Javascript string/integer comparisons - Stack Overflow

    Mar 23, 2016 · Yes it gets a boolean from the < result and coerces it to string, but by then it's too late to affect how the comparison worked. JS < operator behavior depends on its two …

  7. javascript - Check if string contains only digits - Stack Overflow

    Here's another interesting, readable way to check if a string contains only digits. This method works by splitting the string into an array using the spread operator, and then uses the every() …

  8. How does adding String with Integer work in JavaScript?

    Nov 29, 2016 · In JavaScript, the + operator is used for both numeric addition and string concatenation. When you "add" a number to a string the interpreter converts your number to a …

  9. Javascript: Converting String to Number? - Stack Overflow

    Is there any way to convert a variable from string to number? For example, I have var str = "1"; Can I change it to var str = 1;

  10. Pad a number with leading zeros in JavaScript - Stack Overflow

    Apr 9, 2012 · } When you initialize an array with a number, it creates an array with the length set to that value so that the array appears to contain that many undefined elements. Though some …