Q:

javascript to integer

var myInt = parseInt("10.256"); //10
var myFloat = parseFloat("10.256"); //10.256
70

 var a = parseInt("10");

 
3
var myInt = parseInt("10.256"); //10
var myFloat = parseFloat("10.256"); //10.256
3
//It accepts two arguments. 
//The first argument is the string to convert. 
//The second argument is called the radix. This is the base number used in mathematical systems. For our use, it should always be 10.


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


// returns 42
5
var text = '42px';
var integer = parseInt(text, 10);
// returns 42
4
var text = '3.14someRandomStuff';
var pointNum = parseFloat(text);
// returns 3.14
4
parseInt("1")
1

New to Communities?

Join the community