Check out example codes for "string to int javacsript". It will help you in understanding the concepts better.

Code Example 1

var a = parseInt("10");

Code Example 2

var text = '42px';
var integer = parseInt(text, 10);
// returns 42

Learn ReactJs, React Native from akashmittal.com