string to int javascript
snippet in javascript

string to int javascript

Noob codes official

var x = Number("33389")

how to convert string to int js

user5207

let string = "1";
let num = parseInt(string);
//num will equal 1 as a int

string to int javascript

user471

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

string to int javascript

user8999

var text = '42px';
var integer = parseInt(text, 10);
// returns 42
let myNumber = Number("5.25"); //5.25

string to int javascript

user1194

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

string to int javascript

user1850

var text = '3.14someRandomStuff';
var pointNum = parseFloat(text);
// returns 3.14

string to int javascript

user9602

// Convert strings
Number('123'); // returns 123
Number('12.3'); // returns 12.3
Number('3.14someRandomStuff'); // returns NaN
Number('42px'); // returns NaN