1
How to convert string to number in rect?
I have a function that receives two parameters of type number(2,6), however, when sending them from one screen to another it is received as string.
How do I convert?
1
How to convert string to number in rect?
I have a function that receives two parameters of type number(2,6), however, when sending them from one screen to another it is received as string.
How do I convert?
3
In Native:
var stringToNumber = "23";
var numberValue = utilsModule.convertString(stringToNumber);
reference: https://docs.nativescript.org/core-concepts/utils
Javascript:
var number = parseInt(id.substring(indexPos) , 10 ) + 1;
reference: https://stackoverflow.com/a/18713579/7920143
I hope I’ve helped.
1
It worked for me like this:
Number(string);
1
Convert a string
for number
in React Native is the same problem to do this in Javascript, which is the language used by the framework. So just use the parseFloat()
:
parseFloat("123.45") // => 123.45 (Number)
Another more "exotic" way to convert is by using the plus sign:
+"123.45" // => 123.45
Browser other questions tagged react-native
You are not signed in. Login or sign up in order to post.
how do I import the
utilsModule
?– Italo Rodrigo
If not installed on this link you have the instruction: https://www.npmjs.com/package/nativescript-utils If you are installed on this link you can do JS and Typescript. https://docs.nativescript.org/core-concepts/utils .
– alxwca