So konvertieren Sie String in Int JS
let string = "1";
let num = parseInt(string);
//num will equal 1 as a int
Unusual Unicorn
let string = "1";
let num = parseInt(string);
//num will equal 1 as a int
var myInt = parseInt("10.256"); //10
var myFloat = parseFloat("10.256"); //10.256
let myNumber = Number("5.25"); //5.25
// Converting a String into a Number in Javascript
// Longhand:
const num1 = parseInt("100");
const num2 = parseFloat("100.01");
console.log(num1);
console.log(num2);
// Shorthand:
const num3 = +"100"; // converts to int data type
const num4 = +"100.01"; // converts to float data type
console.log(num3);
console.log(num4);
var text = '42px';
var integer = parseInt(text, 10);
// returns 42
let num = parseInt(string); //int num