Convert string to number in js

Hello all, Sometime you need to convert your strings with number or numbers to string in javscript.

You can use some javascript functions for it.

  1. Number() function
  2. parseInt()
  3. parseFloat()

Let’s talk about first one.

<script>
const a = "5";
Number(a);
</script>

Above code will show a as 5.

Now let’s see parseInt() method

<script>
const a = "5";
parseInt(a);
</script>

Above code will show a as 5.

Same will work for parseFloat().

Blog Catagory : JAVASCRIPT