Convert string to number

1

How to convert string into number into rect native?

I have a function that receives two parameters of type number (2.6), but when I send them from one screen to another it is received as a string.

How do I do the conversion?

    
asked by anonymous 12.01.2018 / 11:51

3 answers

0

It worked for me like this:

Number(string);

    
19.01.2018 / 22:17
2

In native:

var stringToNumber = "23";
var numberValue = utilsModule.convertString(stringToNumber);

reference: link

In JavaScript:

 var number = parseInt(id.substring(indexPos) , 10 ) + 1;

reference: link

I hope I have helped.

    
12.01.2018 / 12:00
1

Converting a string to number into React Native is the same problem as doing this in JavaScript, which is the language used by the framework. So just use parseFloat() :

parseFloat("123.45") // => 123.45 (Number)

Another more "exotic" way of converting is by using the plus sign:

+"123.45" // => 123.45
    
16.01.2018 / 02:15